mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-08-22 03:18:54 +08:00
fix(summary): keep every text block in structured tool results (#1619)
formatResultContent recognized structured tool output shaped like
`[{ type: "text", text: "..." }]` but read only `parsedContent[0].text`.
When a tool result split its output across several text blocks, the step
summary showed the first and silently dropped the rest, so extra findings,
file paths and follow-up instructions vanished from the rendered
Claude Code Report while remaining in the execution transcript.
Collect the text from every block instead of just the first. Blocks of other
types, such as images, are skipped rather than stringified into the summary.
Fixes #1572
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
8b8745859f
commit
a2489efcb9
@@ -111,6 +111,42 @@ describe("formatResultContent", () => {
|
||||
const result = formatResultContent(JSON.stringify(structuredContent));
|
||||
expect(result).toBe("**→** Hello world\n\n");
|
||||
});
|
||||
|
||||
test("keeps every text block, not just the first", () => {
|
||||
const structuredContent = [
|
||||
{ type: "text", text: "first line" },
|
||||
{ type: "text", text: "second line" },
|
||||
{ type: "text", text: "third line" },
|
||||
];
|
||||
const result = formatResultContent(JSON.stringify(structuredContent));
|
||||
|
||||
expect(result).toContain("first line");
|
||||
expect(result).toContain("second line");
|
||||
expect(result).toContain("third line");
|
||||
});
|
||||
|
||||
test("keeps every text block when given an array directly", () => {
|
||||
const result = formatResultContent([
|
||||
{ type: "text", text: "alpha" },
|
||||
{ type: "text", text: "beta" },
|
||||
]);
|
||||
|
||||
expect(result).toContain("alpha");
|
||||
expect(result).toContain("beta");
|
||||
});
|
||||
|
||||
test("skips non-text blocks while keeping the text ones", () => {
|
||||
const structuredContent = [
|
||||
{ type: "text", text: "visible" },
|
||||
{ type: "image", source: { data: "ignored-binary" } },
|
||||
{ type: "text", text: "also visible" },
|
||||
];
|
||||
const result = formatResultContent(JSON.stringify(structuredContent));
|
||||
|
||||
expect(result).toContain("visible");
|
||||
expect(result).toContain("also visible");
|
||||
expect(result).not.toContain("ignored-binary");
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatToolWithResult", () => {
|
||||
|
||||
Reference in New Issue
Block a user