From a1c0599a9cb8c343d8ff10e5e545b2a6f6ae668b Mon Sep 17 00:00:00 2001 From: anish <145943060+anishesg@users.noreply.github.com> Date: Wed, 15 Jul 2026 20:27:23 -0700 Subject: [PATCH] fix(format): filter out thinking_tokens system messages from step summary (#1479) ## Summary Signed-off-by: anish Co-authored-by: anish --- src/entrypoints/format-turns.ts | 3 ++- test/format-turns.test.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) mode change 100755 => 100644 src/entrypoints/format-turns.ts diff --git a/src/entrypoints/format-turns.ts b/src/entrypoints/format-turns.ts old mode 100755 new mode 100644 index 32417459..c18ab49f --- a/src/entrypoints/format-turns.ts +++ b/src/entrypoints/format-turns.ts @@ -268,7 +268,8 @@ export function groupTurnsNaturally(data: Turn[]): GroupedContent[] { type: "system_init", tools_count: tools.length, }); - } else { + } else if (subtype !== "thinking_tokens") { + // Skip thinking_tokens - internal progress events not meant for summary groupedContent.push({ type: "system_other", data: turn, diff --git a/test/format-turns.test.ts b/test/format-turns.test.ts index e6ac058b..7b59bbe4 100644 --- a/test/format-turns.test.ts +++ b/test/format-turns.test.ts @@ -484,4 +484,34 @@ describe("system_other handling", () => { ]); expect(markdown).toContain("## ⚙️ System Message"); }); + + test("filters out thinking_tokens system messages", () => { + const data: Turn[] = [ + { type: "system", subtype: "init", tools: [{ name: "tool1" }] }, + { type: "system", subtype: "thinking_tokens" }, + { type: "system", subtype: "thinking_tokens" }, + { type: "system", subtype: "other_subtype" }, + ]; + + const grouped = groupTurnsNaturally(data); + + // Should have init and other_subtype, but not thinking_tokens + expect(grouped).toHaveLength(2); + expect(grouped[0]?.type).toBe("system_init"); + expect(grouped[1]?.type).toBe("system_other"); + expect(grouped[1]?.data?.subtype).toBe("other_subtype"); + }); + + test("thinking_tokens does not appear in formatted output", () => { + const data: Turn[] = [ + { type: "system", subtype: "init", tools: [] }, + { type: "system", subtype: "thinking_tokens" }, + { type: "system", subtype: "thinking_tokens" }, + ]; + + const result = formatTurnsFromData(data); + + expect(result).not.toContain("thinking_tokens"); + expect(result).toContain("## 🚀 System Initialization"); + }); });