Skip to content

Anthropic Messages JSON-stringifies image media returned from tool results #28861

@kitlangton

Description

@kitlangton

Problem

The native Anthropic Messages protocol lowers every tool-result into a string via toolResultText. For content-typed tool results, that JSON-stringifies the whole content array, including base64 image data, into tool_result.content.

That shape silently inflates the prompt. In a long conversation, a screenshot/read tool result can push a later turn over the model context limit.

Expected

  • Tool-result image media should be emitted as Anthropic-native image blocks inside tool_result.content.
  • Text/json/error tool results should keep the existing string behavior.
  • Unsupported non-image tool-result media should fail clearly.

PR

Metadata

Metadata

Assignees

Labels

needs:complianceThis means the issue will auto-close after 2 hours.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions