refactor: centralize streaming text normalization
This commit is contained in:
@@ -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> => {
|
||||
): 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<string | undefined> => {
|
||||
const text = normalizeStreamingText(payload);
|
||||
if (!text) return undefined;
|
||||
await typingSignals.signalTextDelta(text);
|
||||
return text;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user