feat(gateway): stream thinking events and decouple tool events from verbose level (#10568)

This commit is contained in:
Nate
2026-02-10 19:17:21 -06:00
committed by GitHub
parent d2c2f4185b
commit 2b02e8a7a8
5 changed files with 48 additions and 7 deletions

View File

@@ -7,6 +7,7 @@ import type { SubscribeEmbeddedPiSessionParams } from "./pi-embedded-subscribe.t
import { parseReplyDirectives } from "../auto-reply/reply/reply-directives.js";
import { createStreamingDirectiveAccumulator } from "../auto-reply/reply/streaming-directives.js";
import { formatToolAggregate } from "../auto-reply/tool-meta.js";
import { emitAgentEvent } from "../infra/agent-events.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
import { buildCodeSpanIndex, createInlineCodeState } from "../markdown/code-spans.js";
import { EmbeddedBlockChunker } from "./pi-embedded-block-chunker.js";
@@ -533,7 +534,22 @@ export function subscribeEmbeddedPiSession(params: SubscribeEmbeddedPiSessionPar
if (formatted === state.lastStreamedReasoning) {
return;
}
// Compute delta: new text since the last emitted reasoning.
// Guard against non-prefix changes (e.g. trim/format altering earlier content).
const prior = state.lastStreamedReasoning ?? "";
const delta = formatted.startsWith(prior) ? formatted.slice(prior.length) : formatted;
state.lastStreamedReasoning = formatted;
// Broadcast thinking event to WebSocket clients in real-time
emitAgentEvent({
runId: params.runId,
stream: "thinking",
data: {
text: formatted,
delta,
},
});
void params.onReasoningStream({
text: formatted,
});