Expand description
The JSON a generated #[tool] handler answers with.
§Why this lives here and not in the macro
A generated handler has to turn two Rust things into one wire thing: a
deserialised argument struct, and a Result<T, E>. The shape of a failed
tool call — a text block under content with isError set — is the
specification’s, not the macro author’s. A macro that built the JSON itself
would be free to disagree with ToolResult::error
and with the codec that lowers it, and nothing would notice until a client
read the difference.
So the macro generates a call into success and failure and owns no
document shape at all.
§Why structuredContent is decided here rather than by a codec
It is not decided here — this function emits it, and the codec drops it for
a revision before 2025-06-18. That split is deliberate: whether the field
exists is a codec question, and whether the answer has an object in it
is a Rust question, and putting both in one place would make the codec
re-derive a type it should be handed.
Enums§
- Outcome
Error - Why a generated handler could not produce an answer.