codex_output_schema uses root type: "array" which violates Structured Outputs API requirement

Open 💬 0 comments Opened Apr 2, 2026 by motoritJosha

What version of Codex CLI is running?

codex-cli 0.118.0

What subscription do you have?

API (Pay-as-you-go)

Which model were you using?

gpt-5-codex

What platform is your computer?

Linux ubuntu-latest (Azure Pipelines hosted agent)

What terminal emulator and version are you using (if applicable)?

N/A — running in Azure Pipelines CI/CD

What issue are you seeing?

Description

When running Codex CLI in a CI/CD pipeline (Azure Pipelines, ubuntu-latest), the API
returns a 400 error because codex_output_schema defines the root schema as
type: "array", but the Structured Outputs API requires type: "object" at root level.

Error

ERROR: {
"type": "error",
"error": {
"type": "invalid_request_error",
"code": "invalid_json_schema",
"message": "Invalid schema for response_format 'codex_output_schema': schema must be a JSON Schema of 'type: "object"', got 'type: "array"'.",
"param": "text.format.schema"
},
"status": 400
}

The error fires on every request, making the CLI unusable.
approval_policy = "never"
sandbox_mode = "workspace-write"
model = "gpt-5-codex"
model_reasoning_effort = "medium"

Expected behavior

The root of codex_output_schema should be type: "object" wrapping the array, e.g.:

{
"type": "object",
"properties": {
"results": {
"type": "array",
"items": { ... }
}
},
"required": ["results"],
"additionalProperties": false
}

What steps can reproduce the bug?

  1. Create a codex-config.toml:

```toml
approval_policy = "never"
sandbox_mode = "workspace-write"
model = "gpt-5-codex"
model_reasoning_effort = "medium"

  1. Run Codex in non-interactive/CI mode against any PR or codebase:

codex --config codex-config.toml exec "Review this PR for issues"

  1. Every request fails with HTTP 400:

{
"type": "error",
"error": {
"type": "invalid_request_error",
"code": "invalid_json_schema",
"message": "Invalid schema for response_format 'codex_output_schema': schema must be a JSON Schema of 'type: \"object\"', got 'type:
\"array\"'.",
"param": "text.format.schema"
},
"status": 400
}

The error is deterministic — happens on every invocation, not intermittent.

What is the expected behavior?

Codex should successfully send requests to the API without schema validation errors.

The internal codex_output_schema sent via text.format.schema should have type: "object"
at the root level, since OpenAI's Structured Outputs API requires this.

For example, wrapping the current array in an object:

{
"type": "object",
"properties": {
"results": {
"type": "array",
"items": { ... }
}
},
"required": ["results"],
"additionalProperties": false
}

The command should execute and return results without a 400 error.

Additional information

  • Related Issues: #2459, #4181, #4776

View original on GitHub ↗