Skip to content

ToolResult

The object a handler returns. text is the model-visible body; structured is optional JSON-serializable data some clients display. When the tool declares an output schema, structured is surfaced to the host as the spec structuredContent object alongside the text mirror.

A handler may also return a bare string as shorthand for { text }.

Type ParameterDefault type
Sunknown
PropertyTypeDescription
structured?SOptional structured data attached to the result. Typed by the tool’s declared output schema when there is one, so a handler that returns a shape its own schema does not describe is a compile error at the definition site. Untyped (unknown) for a tool that declares no output, and for a definition not wrapped in tool() — the generic has to be captured somewhere for this to mean anything.
textstringThe model-visible response body. Always provide this.