Bug Description
When using structured outputs with output_format, the StructuredOutput tool intermittently wraps user data in an {"output": {...}} field. Validation fails when the wrapper is present.
This is non-deterministic - same prompt can produce either format:
// Sometimes (works):
{"actions": [...]}
// Sometimes (fails validation):
{"output": {"actions": [...]}}
Impact
ResultMessage.structured_output is None when wrapper is present
- Agent confusion - Claude sees conflicting validation errors and may simplify output (e.g., 47 items → 1 item)
- Flaky results - identical prompts succeed or fail randomly
Tool Response Error
Output does not match required schema: root: must have required property 'actions', root: must NOT have additional properties
This error confuses Claude because:
actions is "required" but exists inside output
- Schema has
additionalProperties: false, so output is invalid
Claude tried to "debug" by reducing output from 47 items to 1 item.
Environment
- claude-agent-sdk==0.1.19
- Python 3.11+
Related
Bug Description
When using structured outputs with
output_format, theStructuredOutputtool intermittently wraps user data in an{"output": {...}}field. Validation fails when the wrapper is present.This is non-deterministic - same prompt can produce either format:
Impact
ResultMessage.structured_outputisNonewhen wrapper is presentTool Response Error
This error confuses Claude because:
actionsis "required" but exists insideoutputadditionalProperties: false, sooutputis invalidClaude tried to "debug" by reducing output from 47 items to 1 item.
Environment
Related
properties/parameters)