From 29b7b2068a2726dfa0cadd0544ccbecd4a1f706a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 12 Jan 2026 22:17:14 +0000 Subject: [PATCH] refactor: centralize streaming text normalization --- src/auto-reply/reply/agent-runner.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/auto-reply/reply/agent-runner.ts b/src/auto-reply/reply/agent-runner.ts index 070a1e7bf..b3e8cea65 100644 --- a/src/auto-reply/reply/agent-runner.ts +++ b/src/auto-reply/reply/agent-runner.ts @@ -547,9 +547,9 @@ export async function runReplyAgent(params: { const allowPartialStream = !( followupRun.run.reasoningLevel === "stream" && opts?.onReasoningStream ); - const handlePartialForTyping = async ( + const normalizeStreamingText = ( payload: ReplyPayload, - ): Promise => { + ): string | undefined => { if (!allowPartialStream) return undefined; let text = payload.text; if (!isHeartbeat && text?.includes("HEARTBEAT_OK")) { @@ -566,6 +566,13 @@ export async function runReplyAgent(params: { text = stripped.text; } if (isSilentReplyText(text, SILENT_REPLY_TOKEN)) return undefined; + return text; + }; + const handlePartialForTyping = async ( + payload: ReplyPayload, + ): Promise => { + const text = normalizeStreamingText(payload); + if (!text) return undefined; await typingSignals.signalTextDelta(text); return text; };