fix: exclude compaction notices from TTS transcript accumulation

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.
This commit is contained in:
zidongdesign 2026-03-08 13:36:49 +08:00 committed by Josh Lehman
parent 88c9ad3026
commit 643eb31ea4
No known key found for this signature in database
GPG Key ID: D141B425AC7F876B
4 changed files with 10 additions and 2 deletions

View File

@ -428,6 +428,7 @@ export async function runAgentTurnWithFallback(params: {
text: "🧹 Compacting context...",
replyToId: currentMessageId,
replyToCurrent: true,
isCompactionNotice: true,
});
await params.opts.onBlockReply(noticePayload);
}

View File

@ -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.

View File

@ -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";
}

View File

@ -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<string, unknown>;
};