Learning resourcesReviewed · OpenAI

Codex non-interactive mode guide

This documentation page explains how developers and continuous integration (CI) maintainers can run Codex, an AI coding agent, from scripts and pipelines using codex exec instead of its interactive terminal interface. It covers codex exec, piped input, JSONL events, schema-constrained final responses, session resumption and a GitHub Actions repair workflow.

Researched 14 Nov 2026

In short.

This Codex guide helps developers and continuous integration (CI) maintainers automate coding tasks with Codex, an AI coding agent, from the command line, but safe use depends on credential isolation, permission settings and reviewing proposed changes. It explains how codex exec handles prompts, piped context, progress events and structured final output. Its CI example separates patch generation from pull-request creation. Execution reliability, output quality and costs are not established.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete selected page at [https://learn.chatgpt.com/docs/non-interactive-mode.md], including authentication cautions, permission settings, output formats, session handling, CI examples and advanced stdin patterns. All linked pages are excluded. No commands, workflows or examples were executed. Runtime behavior, output quality, security effectiveness, release compatibility, pricing and licensing remain unverified where the page supplies no evidence.

The overview

Resource identity

Non-interactive mode is a Codex documentation guide at [https://learn.chatgpt.com/docs/non-interactive-mode.md]. It explains using codex exec to run tasks from scripts without opening Codex's interactive terminal interface. Codex is an AI coding agent that can run commands and change files in a repository, depending on its sandbox setting.

Its scope includes command-line usage, permissions, output handling, authentication, session resumption and automation examples.

Practical assessment

The guide is useful for adding Codex to repository summaries, release-note generation, log triage, pre-merge checks and scheduled jobs. It gives concrete ways to connect shell input and output to an AI task.

Its strongest practical detail is the distinction between final text, an event stream and a schema-constrained response. The CI example also addresses credential exposure and repository write permissions. These documented designs do not establish successful execution or trustworthy fixes.

Intended users

Developers comfortable with shell commands can use the simpler examples to summarize repositories or command output. Beginners will need familiarity with Git, command redirection and credential handling; the page does not teach those foundations.

CI maintainers and tooling developers get more advanced material on JSONL events, JSON Schema, saved sessions, required MCP server failures and separating patch generation from pull-request publication.

Documented capabilities

The guide documents passing a task as an argument, supplying additional context through stdin, using stdin as the entire prompt, and resuming the last session or a specified session ID.

It covers saving the final message with -o or --output-last-message, emitting JSONL events with --json, requesting a schema-constrained final response with --output-schema, and avoiding persisted session rollout files with --ephemeral.

It also describes read-only and write-enabled sandboxes, automatic approval review, and failure when an enabled MCP server marked required cannot initialize.

Using it

Requirements

The shell examples need an installed and authenticated Codex CLI. The GitHub Actions example instead uses openai/codex-action, which installs Codex itself and needs an OPENAI_API_KEY repository secret. Commands normally run inside a Git repository. The page documents --skip-git-repo-check as an override when the operator considers the environment safe.

Installation steps, supported operating systems, model availability and a minimum CLI version are not specified. The GitHub Actions example assumes a Node.js project and uses Node.js 20; that is an example-specific requirement.

How it works

In the default output mode, Codex sends progress to stderr and its final message to stdout. This lets a script save or pipe the final response separately from progress. With --json, stdout becomes a JSONL event stream containing events such as turn completion, item updates and errors.

When a prompt argument accompanies piped input, the argument supplies the instruction and stdin supplies context. Without a prompt argument, stdin supplies the prompt; codex exec - explicitly selects that behavior.

--output-schema requests a final response matching a JSON Schema. This serves a different purpose from JSONL: the schema describes the final answer's structure, while JSONL records events during the run.

Setup guidance

The page says codex exec reuses saved CLI authentication and starts with a read-only sandbox. Editing requires an appropriate permission setting, such as --sandbox workspace-write. It states that --full-auto is no longer supported and describes --approve-for-me as automatic approval review with the workspace-write sandbox.

For GitHub Actions, it recommends openai/codex-action, which it describes as using a Responses API proxy to reduce API-key exposure. The sample installs dependencies before Codex runs, gives patch generation only repository read permissions, and creates the pull request in a separate job.

For other automation environments, the page scopes CODEX_API_KEY to the invocation that needs it and warns against running untrusted code in the same process environment.

Representative examples

The release-note example is: codex exec "generate release notes for the last 10 commits" | tee release-notes.md. It illustrates saving the final response while progress remains on stderr. The accuracy of generated notes is not established.

For structured metadata, the guide shows: codex exec "Extract project metadata" --output-schema ./schema.json -o ./project-metadata.json. Its schema requires project_name and programming_languages and disallows additional properties. This requests a predictable response structure; the correctness of extracted values remains unassessed.

The larger CI example asks Codex to reproduce a failing npm test, make a minimal fix and rerun the test, then saves a patch for a separate pull-request job. It is a documented workflow, with no supplied execution results.

Assessment & evidence

Limitations and cautions

The page supplies no measured accuracy, latency, reliability or security results. Schema conformance, successful session resumption, CI repair quality and failure recovery were not assessed through execution.

Broader access changes the risk of an automated run. The page restricts its danger-full-access recommendation to controlled environments such as isolated runners or containers. It also documents options that skip user configuration or policy rule files; those options require deliberate control of the automation environment.

The advanced account-authentication recipe for trusted runners involves access tokens in auth.json. The page treats this file as a password, excludes public or open-source repositories, and, where codex login is not an option on the runner, says to seed auth.json through secure storage, let Codex refresh it in place and persist the updated file between runs.

Why the design matters

Separating progress from the final answer makes ordinary shell pipelines easier to build. The documented output modes suggest two distinct uses: JSONL for observing a run and schema-constrained final responses for downstream parsing. Neither establishes that the answer is factually correct.

The CI design gives patch generation and pull-request creation different permissions. This creates a useful boundary between work that needs AI credentials and work that needs repository write access. Its effectiveness depends on the actual runner, workflow and credential configuration, which were not assessed.

Related options

The page identifies Codex's interactive terminal interface as another way to work with Codex, but does not compare its features with codex exec. For GitHub Actions, it recommends the Codex GitHub Action over manually installing and authenticating the CLI in a shell step.

It mentions codex review, the TypeScript SDK and codex exec-server --remote as other interfaces that accept CODEX_API_KEY. Their suitability as replacements is not explained. Other products, their capabilities and their costs are not assessed.

Evidence and source

The evidence is the complete selected documentation page at [https://learn.chatgpt.com/docs/non-interactive-mode.md], captured as selected-page.txt. It contains explanatory text, shell examples, sample JSONL, a JSON Schema and a GitHub Actions workflow.

The supplied source revision is sha256:a80f8549209c988749177954b3a295d105d2aa86dae287ba387bc028b4854877. Linked command references, authentication documentation, network-filesystem guidance and GitHub Action security documentation are outside the evidence. No independent execution results are supplied.

Access & freshness

Costs and usage limits

Pricing, quota amounts and per-task charges are unknown. The page distinguishes API-key usage from ChatGPT-managed account rate limits but does not establish subscription eligibility or compare their costs.

The sample JSONL includes token-usage fields. Those illustrative fields do not establish the cost of a real task, a typical workload or repeated CI runs.

Rights and data terms

The selected page does not state a documentation redistribution license, a Codex software license, ownership terms for generated output or service data-retention terms. Those rights and terms are unknown from this source.

--ephemeral is described as preventing session rollout files from being persisted to disk. That statement does not establish server-side deletion or broader privacy guarantees.

Freshness and compatibility

The source was captured on 14 November 2026 at 21:54:25.583 UTC. It does not state a publication date, last-update date or supported Codex CLI version. Changes after that capture are unknown.

The explicit removal of --full-auto is relevant to existing scripts. The page names replacement settings, but compatibility with any particular installed CLI release remains unverified.

Practical next steps

Before integrating a job, confirm the installed CLI's flags, authentication method and required sandbox permissions. Choose final text, JSONL events or a schema-constrained response according to what the next pipeline step needs. Start with a small task whose expected result can be checked before granting write access.

For CI, follow the documented separation of dependency setup, Codex execution and pull-request creation. Keep API keys out of job-level environments that run repository-controlled code, and review generated patches before merging. Consult the linked authentication and security references before deployment; their details are not established by this page alone.

Evidence for this report

selected-page.txtselected · checked 2026-11-14