From 643eb31ea4c4b47c15af9bfe02ed29787d0addfa Mon Sep 17 00:00:00 2001 From: zidongdesign Date: Sun, 8 Mar 2026 13:36:49 +0800 Subject: [PATCH] fix: exclude compaction notices from TTS transcript accumulation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add isCompactionNotice flag to ReplyPayload and set it on both the compaction start notice (agent-runner-execution.ts) and the completion notice (agent-runner.ts). dispatch-from-config.ts skips accumulation into accumulatedBlockText when the flag is set, so compaction status lines (๐Ÿงน / โœ…) are never synthesised into the fallback TTS audio for block-streaming runs with tts.mode=final. --- src/auto-reply/reply/agent-runner-execution.ts | 1 + src/auto-reply/reply/agent-runner.ts | 1 + src/auto-reply/reply/dispatch-from-config.ts | 6 ++++-- src/auto-reply/types.ts | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/auto-reply/reply/agent-runner-execution.ts b/src/auto-reply/reply/agent-runner-execution.ts index c7191b92edd..9998cca29d3 100644 --- a/src/auto-reply/reply/agent-runner-execution.ts +++ b/src/auto-reply/reply/agent-runner-execution.ts @@ -428,6 +428,7 @@ export async function runAgentTurnWithFallback(params: { text: "๐Ÿงน Compacting context...", replyToId: currentMessageId, replyToCurrent: true, + isCompactionNotice: true, }); await params.opts.onBlockReply(noticePayload); } diff --git a/src/auto-reply/reply/agent-runner.ts b/src/auto-reply/reply/agent-runner.ts index 73473949db1..2e93650446b 100644 --- a/src/auto-reply/reply/agent-runner.ts +++ b/src/auto-reply/reply/agent-runner.ts @@ -433,6 +433,7 @@ export async function runReplyAgent(params: { text: completionText, replyToId: currentMessageId, replyToCurrent: true, + isCompactionNotice: true, }); // Fire-and-forget with timeout โ€” best-effort delivery; failure must not // propagate to the caller. diff --git a/src/auto-reply/reply/dispatch-from-config.ts b/src/auto-reply/reply/dispatch-from-config.ts index 9df6ef2bc63..9f603b30863 100644 --- a/src/auto-reply/reply/dispatch-from-config.ts +++ b/src/auto-reply/reply/dispatch-from-config.ts @@ -582,8 +582,10 @@ export async function dispatchReplyFromConfig(params: { if (shouldSuppressReasoningPayload(payload)) { return; } - // Accumulate block text for TTS generation after streaming - if (payload.text) { + // Accumulate block text for TTS generation after streaming. + // Exclude compaction status notices โ€” they are informational UI + // signals and must not be synthesised into the spoken reply. + if (payload.text && !payload.isCompactionNotice) { if (accumulatedBlockText.length > 0) { accumulatedBlockText += "\n"; } diff --git a/src/auto-reply/types.ts b/src/auto-reply/types.ts index c424f43ab92..638dda42d8f 100644 --- a/src/auto-reply/types.ts +++ b/src/auto-reply/types.ts @@ -91,6 +91,10 @@ export type ReplyPayload = { /** Marks this payload as a reasoning/thinking block. Channels that do not * have a dedicated reasoning lane (e.g. WhatsApp, web) should suppress it. */ isReasoning?: boolean; + /** Marks this payload as a compaction status notice (start/end). + * Should be excluded from TTS transcript accumulation so compaction + * status lines are not synthesised into the spoken assistant reply. */ + isCompactionNotice?: boolean; /** Channel-specific payload data (per-channel envelope). */ channelData?: Record; };