In short.
This is a guide for developers who need Claude agents to return data their applications can use, with the catch that a completed run may still contain no usable structured answer. It covers schema configuration in TypeScript and Python, JSON Schema draft-07 compatibility, typed parsing with Zod or Pydantic, and the StructuredOutput tool mechanism. Its most useful operational detail is the requirement to check the final result's subtype, error flag and structured_output together. The examples were not executed; costs, installation prerequisites and licensing are not established by this page.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete selected documentation page at [https://code.claude.com/docs/en/agent-sdk/structured-outputs.md], including all supplied examples, version notices, validation limitations, stream behavior and error handling. Linked pages are excluded, including the documentation index, installation quickstart, full schema limitations, troubleshooting, model fallback documentation, dependency documentation and direct API guide. Runtime behavior, installation, performance, costs and licensing were not independently verified; no code was executed.
The overview
Identity
Get structured output from agents is a Claude Agent SDK documentation guide at [https://code.claude.com/docs/en/agent-sdk/structured-outputs.md]. It explains how to obtain schema-validated JSON after an agent completes work that may involve multiple tool calls.
The TypeScript examples import query from @anthropic-ai/claude-agent-sdk. The Python examples use query, ClaudeAgentOptions and ResultMessage from claude_agent_sdk. The resource is documentation for an SDK feature, rather than a standalone application.
Assessment
The guide is useful when an application's next step needs predictable fields and types, such as displaying extracted records or passing results into application logic. It connects schema definition with result handling instead of stopping at a JSON example.
Its strongest practical material concerns failure handling: a success subtype alone is insufficient, intermediate tool inputs are not the validated final answer, and single-shot query calls can raise after yielding an error result. Integration behavior and example correctness were not tested.
Users
The intended readers are TypeScript and Python developers building applications around Claude agents. Beginners get concrete examples of why prose is awkward to consume programmatically; experienced developers get configuration names, stream details and error conditions.
The examples assume familiarity with asynchronous iteration, objects or dictionaries, and required versus optional fields. They illustrate recipe data, company research, feature planning, contact extraction and codebase TODO tracking.
Capabilities
The documented feature validates final output against a supplied JSON Schema while allowing the agent to use tools during its work. Listed schema features include basic JSON types, enum, const, required fields, nested objects and $ref definitions.
Developers can write JSON Schema directly or generate it from Zod or Pydantic. The typed examples also parse the returned structured_output with Zod safeParse or Pydantic model_validate, making the resulting data usable through the application's declared types.
Using it
Requirements
The page requires installation of the Claude Agent SDK and links to a separate quickstart. Installation commands, authentication requirements, supported runtimes and model availability are not established within this page. Zod or Pydantic is needed only for the corresponding typed approach.
The SDK validator expects JSON Schema draft-07 and rejects schemas declaring a newer version. The guide says Zod targets draft 2020-12 by default and explicitly supplies target: "draft-7" during conversion. It does not enumerate every supported schema restriction locally.
Mechanism
Configuring structured output adds a tool named StructuredOutput to the agent session. The agent submits an object through that tool; a validation failure produces an error tool result and another attempt. If no valid output remains within the retry limit, the run ends with an error.
Applications should consume structured_output from the final result message instead of taking data from an intermediate tool_use block. Applications that hide these internal calls from logs or interfaces must also identify their tool_result blocks through the matching tool_use_id.
Setup
Define the desired fields and requirements, then pass an object containing type: "json_schema" and schema to outputFormat in TypeScript or output_format in Python. The Python examples place this configuration inside ClaudeAgentOptions.
Consume the asynchronous message stream and accept data only when the result subtype is success, is_error is false and structured_output is present. Include exception handling around iteration: the guide states that a single-shot query raises after yielding an error result, while connection or process failures may produce no result message.
Example
The TODO tracking example asks an agent to find TODO comments and identify who added them. Its intended workflow uses Grep to locate comments and Bash to obtain git blame information, then returns a todos array and total_count.
Each TODO requires text, file and line. Author and date are optional because blame information may be unavailable. This illustrates how to represent missing information without requiring every record to contain it. The example supplies no observed search results or evidence that every TODO was found.
Assessment & evidence
Limitations
Schema validation establishes conformity to the declared structure, not factual accuracy or task completeness. The guide explicitly says format is only an annotation: a string marked format: "email" is not checked for email validity by the SDK validator.
A model fallback can retract an already-completed output. If no successful retry replaces it, the run can end with error_max_structured_output_retries even without a schema validation failure; the errors list helps distinguish these causes. An error result must not be used even if it carries structured_output.
The examples also differ in constraint strength: the TypeScript feature-plan schema restricts estimated_complexity to low, medium or high, whereas the Python model declares it as str with a comment. That Python declaration does not express the same three-value restriction.
Reasoning
The guide's practical value follows from moving output structure into an explicit contract: field names, types and required values are declared before the agent works. This can reduce application-specific parsing of prose, provided the application also handles failures and checks the meaning of returned data.
Its advice to keep schemas focused and make unavailable information optional is sensible for extraction tasks. A schema that demands facts the task cannot supply creates avoidable failure pressure; permitting absence makes the expected uncertainty explicit.
Alternatives
Free-form text is the guide's baseline alternative and may suit conversational responses. When an application needs fields, that approach requires its own parsing and handling of inconsistent formatting. Within structured output, handwritten JSON Schema avoids a schema-library dependency, while Zod and Pydantic support typed models.
The page also points to direct Claude API structured outputs for single-turn requests without tool use at [https://platform.claude.com/docs/en/build-with-claude/structured-outputs]. That linked resource is outside the supplied scope, so its implementation details, costs and comparative performance are not assessed.
Evidence
The evidence is the complete selected Claude documentation page at [https://code.claude.com/docs/en/agent-sdk/structured-outputs.md], including its examples, configuration guidance, error handling and related-resource links. It supports statements about documented behavior, not independent runtime performance or reliability.
The captured source is identified by SHA-256 e9e1254217642a03b1b5dc046b43102443b7c7cfcfc3c0590efb9468f8b5ae75. No SDK installation, example execution, benchmark or application integration test was performed.
Access & freshness
Costs
The page provides no prices, subscription requirements, token usage, per-run costs or information about any separate charge for structured output. Cost is unknown.
The documented workflow can involve tool calls and repeated output attempts, but the page provides no measurements of their latency, resource use or billing impact. It also does not state the numeric retry limit or how to configure it.
Rights
The supplied page contains no explicit license or redistribution grant for its documentation or code examples. It also does not establish SDK licensing, commercial-use terms, ownership of generated output or data-handling terms.
Permission to redistribute the captured page or bundle its examples is therefore unknown. The linked SDK and dependency resources were not assessed for licensing.
Freshness
The supplied capture is dated 2026-11-14T21:19:22.102Z. The page does not establish its publication date, last revision date or the latest SDK release.
It names v2.1.205 as a behavior boundary: before that version, invalid schemas were silently ignored, and schemas containing format were treated as invalid. The documented newer behavior rejects invalid schemas at startup and accepts format without enforcing it. Compatibility with any particular installed SDK version remains unverified.
Actions
Before adoption, establish the installation, authentication and runtime requirements from the SDK quickstart. Start with a small schema, require only information the task can reasonably supply, and ensure generated schemas target the supported draft.
Add final-result checks and exception handling before connecting output to application logic. Verify domain rules separately, including email validity, permitted complexity values or agreement between total_count and array length where relevant. Exercise missing-data and failure cases in your own environment, and obtain pricing and licensing information before committing to deployment.
