In this article
A schema makes the final response structurally predictable; the application must still interpret the reported evidence and inspect the referenced artifacts.
A noninteractive Codex task often needs to return data to another program. The documented output-schema option constrains the final response to a JSON shape. That gives the next stage stable fields without making the field values automatically sufficient for a deployment or review decision.
Choose fields that answer the next stage’s questions
An illustrative review schema can identify affected paths, describe validation and retain unresolved questions. Each field has a distinct consumer. Avoid using a single success string to carry all of that information, because downstream code would need to recover structure from prose before it could decide what to show.
{
"type": "object",
"properties": {
"changed_paths": { "type": "array", "items": { "type": "string" } },
"validation": { "type": "string" },
"remaining_questions": { "type": "array", "items": { "type": "string" } }
},
"required": ["changed_paths", "validation", "remaining_questions"],
"additionalProperties": false
}
Request the final artifact explicitly
The noninteractive documentation describes —output-schema and the output-last-message option. The example below requests the schema and saves the final response to a named file. It assumes a prepared repository and an existing schema file; it does not perform those setup steps or execute a real review in this article.
codex exec "Inspect the change and return a review summary" --output-schema ./review-schema.json -o ./review-result.json
Give an empty collection a defined meaning
An empty changed_paths array can mean that no relevant edits were found. It should not silently mean that the process failed to inspect the repository. Define what evidence must accompany that state. Likewise, unresolved questions should remain an explicit collection rather than disappear into an optional paragraph that the consumer never reads.
Keep artifact checks outside the text field
The consumer can verify that returned paths belong to the intended workspace and that the referenced files exist. This is application logic around the result, not an additional property guaranteed by a JSON schema. A small field map makes the responsibility concrete.
| Field | Intended meaning | Downstream use |
|---|---|---|
| changed_paths | Files included in the review | Locate the actual artifacts before showing a diff. |
| validation | What was checked and what was observed | Present evidence without inferring execution from an empty field. |
| remaining_questions | Unresolved task dependencies | Keep uncertainty visible instead of converting it to approval. |
Test the consumer with contrasting results
A proposed fixture can include a complete review, a valid empty result and a response listing unresolved inputs. The consumer should display each state honestly. This tests the handoff between Codex and the application. It does not measure model accuracy, and it should not fabricate test execution merely because the final JSON parsed successfully.
Documentation and further study
Related engineering guides: Reproducible inference stacks: preserving a GPU pilot’s result; Choose a local AI stack: desktop chat, shared UI or coding agent.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.