diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.ts index 3219e0634..3fd3f08ab 100644 --- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts +++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts @@ -3828,20 +3828,18 @@ export class InteractiveMode { const transformations = diagnostic.details?.transformations; if (!Array.isArray(transformations)) continue; - const dropped = transformations.flatMap((transformation): string[] => { - if (typeof transformation !== "object" || transformation === null) return []; - const details = transformation as Record; - if (details.type !== "thinking_dropped") return []; - const reason = typeof details.reason === "string" ? details.reason : "unknown reason"; - const location = typeof details.path === "string" ? ` at ${details.path}` : ""; - return [`${reason}${location}`]; - }); - if (dropped.length === 0) continue; + const droppedCount = transformations.filter( + (transformation) => + typeof transformation === "object" && + transformation !== null && + (transformation as Record).type === "thinking_dropped", + ).length; + if (droppedCount === 0) continue; - const noun = dropped.length === 1 ? "thinking block" : `${dropped.length} thinking blocks`; + const noun = droppedCount === 1 ? "1 thinking block" : `${droppedCount} thinking blocks`; this.chatContainer.addChild(new Spacer(1)); this.chatContainer.addChild( - new Text(theme.fg("warning", `Anthropic dropped ${noun}: ${dropped.join("; ")}`), 1, 0), + new Text(theme.fg("warning", `Anthropic dropped ${noun} (details in session)`), 1, 0), ); } } diff --git a/packages/coding-agent/test/interactive-mode-assistant-diagnostics.test.ts b/packages/coding-agent/test/interactive-mode-assistant-diagnostics.test.ts index 30a13efa4..e890cacf4 100644 --- a/packages/coding-agent/test/interactive-mode-assistant-diagnostics.test.ts +++ b/packages/coding-agent/test/interactive-mode-assistant-diagnostics.test.ts @@ -32,6 +32,16 @@ const message: AssistantMessage = { path: "messages.2.content.0", reason: "prefix_binding_mismatch", }, + { + type: "thinking_dropped", + path: "messages.5.content.0", + reason: "prefix_binding_mismatch", + }, + { + type: "thinking_dropped", + path: "messages.8.content.0", + reason: "prefix_binding_mismatch", + }, ], }, }, @@ -55,7 +65,7 @@ describe("InteractiveMode assistant diagnostics", () => { }; maybeShowAssistantDiagnostics.call(enabled, message); const output = stripAnsi(enabled.chatContainer.render(120).join("\n")); - expect(output).toContain("Anthropic dropped thinking block: prefix_binding_mismatch at messages.2.content.0"); + expect(output).toContain("Anthropic dropped 3 thinking blocks (details in session)"); const disabled = { chatContainer: new Container(),