Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Accept a JSON Schema document as `output_type`

Closed
#5,344 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
ai

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=True runs ensure_strict_json_schema as AgentOutputSchema does; strict=False sends the schema as given, since user-authored schemas often fall outside the strict subset.
  • validate_json parses and validates against the schema and raises ModelBehaviorError on 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openai/openai-agents-python

All issues in openai/openai-agents-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.