BUG: --output-schema limited to "gpt-5" as guard is too narrow on model_family.family

Resolved 💬 4 comments Opened Sep 24, 2025 by ben-vargas Closed Sep 24, 2025

What version of Codex is running?

codex-cli 0.41.0

Which model were you using?

gpt-5-codex

What platform is your computer?

Linux 6.8.0-83-generic x86_64 x86_64

What steps can reproduce the bug?

  1. Create a JSON Schema file (e.g. schema.json) describing the expected final answer.
  2. Run codex exec --output-schema schema.json -m gpt-5-codex 'tell me a joke'.
  3. Observe via logging or a mock server that the outbound payload’s text field is null/missing; the response is unstructured text instead of JSON.
  4. Repeat with -m gpt-5; the schema is honored and the model returns JSON.

What is the expected behavior?

Codex models also support the --output-schema flag.

What do you see instead?

  • The new --output-schema feature attaches a JSON Schema via the OpenAI Responses text.format field, but the client only includes that block when model_family.family == "gpt-5" (core/src/client.rs:187).
  • For any Codex-branded model (slugs starting with gpt-5-codex or codex-), find_family_for_model assigns family to the slug itself (core/src/model_family.rs:70-79), so the equality check never passes.
  • As a result, running codex exec --output-schema schema.json -m gpt-5-codex … (or any other Codex slug) sends a request without text.format, the schema is dropped, and the model produces unconstrained free-form output. This is already in the 0.41.0 release.

Additional information

Scope / Impact

  • All Codex-family models using the new --output-schema path ignore the schema, so the flagship use case of constrained Codex output does not work in 0.41.0.
  • Feature works only for plain GPT‑5 slugs, so parity across model presets is broken.

Suspected Fix

  • Broaden the guard in core/src/client.rs to include model families whose slug starts with gpt-5-codex (and likely other Codex prefixes) before calling create_text_param_for_request, rather than relying on an exact "gpt-5" match.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗