Accept a JSON Schema document as `output_type`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start from AgentOutputSchema and the AgentOutputSchemaBase interface it implements, specifically json_schema(), is_strict_json_schema() and validate_json(), plus how ModelBehaviorError is raised during output parsing. Decide the validation approach first, since the issue leaves open whether to add jsonschema as an optional extra or skip local validation when strict=True. Done means a JsonSchemaOutput class that passes its schema through unchanged when strict=False, returns a parsed dict, and raises ModelBehaviorError on invalid JSON or schema violations, with tests for both modes.
Written by the indexing model from the issue text.
Description
Please read this first
- Have you read the docs? Yes
- Have you searched for related issues? Yes
Describe the feature
AgentOutputSchema takes a Python type, so an agent whose response schema arrives at runtime as JSON Schema (user-defined agents in agent-builder products, schemas stored in config) needs a hand-written AgentOutputSchemaBase subclass that re-implements json_schema(), is_strict_json_schema() and validate_json(), with its own JSON parsing, validation and ModelBehaviorError mapping.
Proposal: a built-in output schema that takes the document directly, e.g.
Agent(..., output_type=JsonSchemaOutput(schema, name="ticket", strict=False))
strict=Truerunsensure_strict_json_schemaasAgentOutputSchemadoes;strict=Falsesends the schema as given, since user-authored schemas often fall outside the strict subset.validate_jsonparses and validates against the schema and raisesModelBehaviorErroron invalid JSON or a schema violation, so retries and error handling match typed outputs.- It returns the parsed dict.
Validation could use jsonschema as an optional extra, or skip local validation when strict=True, where the provider already enforces the schema.
- Dominant language
- Python
- Stars
- 30k
- Forks
- 4.9k
- Avg merge
- 18h 13m
- Merged PRs (30d)
- 215
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openai/openai-agents-python
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
openai/openai-agents-python#5348 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
openai/openai-agents-python#5353 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 Half a day Newbie friendliness 70/100
openai/openai-agents-python#5342 · 3 comments ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 65/100
openai/openai-agents-python#5336 · 1 comment ·
Maintainers usually reply within 1 day
-
Finished tool call is dropped when a parallel tool's guardrail tripsPossibly taken @jbeckwith-oai claimed this 6 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
openai/openai-agents-python#5327 · 1 comment ·
Maintainers usually reply within 1 day
All issues in openai/openai-agents-python
Similar issues
-
Atomic append fails to create a missing filePossibly taken @harbinresearcher claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
fabiocaccamo/python-fsutil#201 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
task
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
danparshall/claude_researcher#87 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
GhostManager/Ghostwriter#998 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
datajoint/datajoint-python#1586 ·
Maintainers usually reply within 1 day