Skip to content

fix(format-turns): render MCP tool error text blocks in step summary - #1846

Open
syf2211 wants to merge 1 commit into
anthropics:mainfrom
syf2211:fix/mcp-error-content-formatting
Open

syf2211 wants to merge 1 commit into
anthropics:mainfrom
syf2211:fix/mcp-error-content-formatting

Conversation

@syf2211

@syf2211 syf2211 commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix step summary rendering for failed MCP tool calls whose content is a text-block array.

Motivation

Fixes #1841. MCP servers (including this action's own MCP server) return tool errors as [{ type: "text", text: "..." }]. The error branch interpolated toolResult.content directly, which stringified to [object Object]. The success path already handled this shape via formatResultContent.

Changes

  • Extract extractToolResultText and normalizeToolResultText helpers from formatResultContent
  • Use normalizeToolResultText in the error branch so MCP text blocks render as plain error text
  • Add regression test for MCP-shaped error content

Tests

  • bun test test/format-turns.test.ts47 passed
  • bun run typecheckpassed
  • composer-2.5 pre-submit review: APPROVE

Notes

Error messages now also receive the same secret redaction and 3000-char truncation as successful tool results.

The error branch interpolated toolResult.content directly, so MCP error
payloads shaped as [{ type: "text", text: "..." }] stringified to
[object Object]. Reuse the same text extraction path as successful
results via normalizeToolResultText.

Fixes anthropics#1841
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failing MCP tool calls render [object Object] in the step summary

1 participant