From a8680f9a09f6a3079904df411b6ef1f5021ccdd4 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 12 Jan 2026 22:58:21 +0000 Subject: [PATCH] fix(auto-reply): fix streaming block reply media handling --- src/auto-reply/reply/agent-runner.ts | 7 ++++--- src/auto-reply/reply/directive-handling.ts | 24 ++++++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/auto-reply/reply/agent-runner.ts b/src/auto-reply/reply/agent-runner.ts index 26d981416..037e38e84 100644 --- a/src/auto-reply/reply/agent-runner.ts +++ b/src/auto-reply/reply/agent-runner.ts @@ -565,7 +565,8 @@ export async function runReplyAgent(params: { } text = stripped.text; } - if (isSilentReplyText(text, SILENT_REPLY_TOKEN)) return { skip: true }; + if (isSilentReplyText(text, SILENT_REPLY_TOKEN)) + return { skip: true }; return { text, skip: false }; }; const handlePartialForTyping = async ( @@ -713,8 +714,8 @@ export async function runReplyAgent(params: { blockStreamingEnabled && opts?.onBlockReply ? async (payload) => { const { text, skip } = normalizeStreamingText(payload); - const hasMedia = (payload.mediaUrls?.length ?? 0) > 0; - if (skip && !hasMedia) return; + if (skip && (payload.mediaUrls?.length ?? 0) === 0) + return; const taggedPayload = applyReplyTagsToPayload( { text, diff --git a/src/auto-reply/reply/directive-handling.ts b/src/auto-reply/reply/directive-handling.ts index 658425b12..c10040c94 100644 --- a/src/auto-reply/reply/directive-handling.ts +++ b/src/auto-reply/reply/directive-handling.ts @@ -629,13 +629,15 @@ export async function applyInlineDirectivesFastLane(params: { provider: string; model: string; initialModelLabel: string; - formatModelSwitchEvent: (label: string, alias?: string) => string; - agentCfg?: NonNullable["defaults"]; - modelState: { - resolveDefaultThinkingLevel: () => Promise; - allowedModelKeys: Set; - allowedModelCatalog: Awaited< - ReturnType + formatModelSwitchEvent: (label: string, alias?: string) => string; + agentCfg?: NonNullable["defaults"]; + modelState: { + resolveDefaultThinkingLevel: () => Promise; + allowedModelKeys: Set; + allowedModelCatalog: Awaited< + ReturnType< + typeof import("../../agents/model-catalog.js").loadModelCatalog + > >; resetModelOverride: boolean; }; @@ -1357,7 +1359,9 @@ export async function handleDirectiveOnly(params: { } } if (directives.hasQueueDirective && directives.queueMode) { - parts.push(formatDirectiveAck(`Queue mode set to ${directives.queueMode}.`)); + parts.push( + formatDirectiveAck(`Queue mode set to ${directives.queueMode}.`), + ); } else if (directives.hasQueueDirective && directives.queueReset) { parts.push(formatDirectiveAck("Queue mode reset to default.")); } @@ -1373,7 +1377,9 @@ export async function handleDirectiveOnly(params: { parts.push(formatDirectiveAck(`Queue cap set to ${directives.cap}.`)); } if (directives.hasQueueDirective && directives.dropPolicy) { - parts.push(formatDirectiveAck(`Queue drop set to ${directives.dropPolicy}.`)); + parts.push( + formatDirectiveAck(`Queue drop set to ${directives.dropPolicy}.`), + ); } const ack = parts.join(" ").trim(); if (!ack && directives.hasStatusDirective) return undefined;