With the SDKs
Pass a Pydantic model asanswer_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 asanswer_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:
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.