Skip to main content
By default the agent answers in free-form text. Give it a schema and the answer becomes JSON that conforms to it.

With the SDKs

Pass a Pydantic model as answer_schema or a Zod v4 schema as answerSchema. The SDK derives the JSON Schema, sends it, and parses the final answer into a typed instance.

With a JSON Schema

Without an SDK, set a JSON Schema as answer_format on the agent, or per run with the agent.answer_format override. The settled answer (latest_answer on the session, answer on changes) is a JSON object matching it.
If every attempt fails to match the schema, the session fails with error_code: answer_validation.

Chaining agents

A typed answer makes an agent callable like a function: one agent’s output feeds the next. Here a scout finds sources, then readers run in parallel (each counts against your concurrency limit):
Related: Configure an agent, Parallelize work with subagents