Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Accept a JSON Schema document as `output_type`

Aperta
#5,344 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
ai

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
29.9k
Fork
4.8k
Merge medio
22h 17m
PR unite (30g)
208

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openai/openai-agents-python

Tutte le issue di openai/openai-agents-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.