Documentation Index
Fetch the complete documentation index at: https://docs.meshagent.com/llms.txt
Use this file to discover all available pages before exploring further.
AnthropicMessagesToolResponseAdapter is the default ToolResponseAdapter used whenever you pair an agent with the Anthropic Messages adapter. It converts tool outputs into Anthropic tool_result blocks and provides a plain-text fallback that hosts can display or log.
Behavior summary
- Plain-text rendering:
to_plain_textgenerates concise strings for common response types (LinkChunk,JsonChunk,TextChunk,FileChunk,EmptyChunk). - Chat context updates:
create_messagesreturns a user message containing atool_resultblock so the model can consume tool output on the next turn. - Attachment handling: Images and PDFs are converted into Anthropic
imageordocumentblocks; unsupported image types fall back to text. - Developer logging: Emits events via
room.developer.log_nowaitto aid debugging when tools are called.
Response handling
| Response type | Plain text example | Notes |
|---|---|---|
TextChunk | The returned text | Included as a text block in the tool_result. |
JsonChunk | JSON string dump | Included as a text block in the tool_result. |
FileChunk | filename.ext | Images (image/jpeg, image/png, image/gif, image/webp) are embedded as Anthropic image blocks; PDFs become document blocks; other files fall back to text. |
LinkChunk | { "name": ..., "url": ... } | Serialized to JSON and included as a text block. |
EmptyChunk | "ok" | Signals successful execution without additional data. |
RawOutputsChunk | n/a | Passed through directly as Anthropic message blocks, bypassing plain-text conversion. |
Tool use requirements
Anthropic requires tool results to include atool_use_id. The adapter raises an error if the tool_use block is missing an id.
Extending or replacing
You can subclassAnthropicMessagesToolResponseAdapter to customize plain-text formatting or message content, provided the emitted messages still follow Anthropic’s tool_result schema. Alternatively, supply your own adapter instance when constructing the agent.
Where it is used
- Automatically when you construct
AnthropicMessagesAdapterwithout specifying a customtool_adapter. - Any agent that wants to reuse the same Anthropic formatting logic can import and instantiate it directly.
Related references
- Adapters Overview: Understand LLMAdapters and ToolResponseAdapters
- Anthropic Messages Adapter: Understand the LLM integration that uses this adapter.