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
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, intotool_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
imageblocks insidetool_result.content.PR