This page works best after Examples: Sessions. Start there if you have not already seen the basic create/turn/result flow.
Basic extraction
Provide anoutput_schema and the agent will extract validated JSON after the agentic loop completes.
- CLI
- JSON-RPC
- REST
- MCP
- Python
- TypeScript
- Rust
Next step
Schema from file
The CLI can load a schema from a JSON file instead of inline.name, strict, compat, and format fields.
Retries
When validation fails, the agent retries the extraction turn with error feedback. The default is 2 retries (3 total attempts).- CLI
- JSON-RPC
- REST
- MCP
- Python
- TypeScript
- Rust
Compatibility mode
Schemas are normalized across providers. Thecompat setting controls how unsupported JSON Schema features are handled during provider-specific lowering.
Warnings are included in the response as
schema_warnings. The same schema works with Anthropic, OpenAI, and Gemini — provider-specific lowering is handled transparently.
Read the result
The structured output appears in the response alongside the committed main-turn text. The extraction JSON does not replacetext.
- CLI
- JSON-RPC
- REST
- MCP
- Python
- TypeScript
- Rust
run_completed for the main output with extraction_required: true, followed
by exactly one extraction_succeeded or extraction_failed event. Extraction
attempts do not stream as ordinary assistant text and do not publish extra
turn_completed events. A schema-compilation failure emits
extraction_failed directly, without a preceding success-shaped
turn_completed or run_completed event.