Skip to main content

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. The raw wire value stays on final_changes / finalChanges. Don’t also set an agent.answer_format override: the SDK rejects the pair.

With a JSON Schema

Without an SDK, set a JSON Schema as answer_format on the agent, or per session with the agent.answer_format override. The settled answer (latest_answer on the session, answer on changes) is a JSON object matching it. A real session with agent.answer_format set to a { sets: [{ name, pieces, price }] } schema:
If the answer never matches, even after retries, the session fails with error_code: answer_validation. The SDKs raise AnswerValidationError (raw payload attached) when a completed session’s answer is missing or doesn’t parse. A failed session’s answer passes through unvalidated.

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):