Codex: stdin is not a terminal — interactive shell or script?
This error happens at the terminal-input boundary. First check how Codex was launched: an automated job should use non-interactive mode, while an interactive launch needs a working terminal.
Start here
Check whether you want an interactive conversation or an automated script; they use different CLI entry points.
Choose the launch you intended
| Where the error appears | Next check | What a useful result looks like |
|---|---|---|
| A script, pipeline, CI job, or another agent’s command runner | Inspect whether it launches the interactive CLI | An automation entry point runs without opening a terminal UI. |
| A terminal where you are typing commands yourself | Compare a direct launch with the wrapper or IDE launch | You can identify whether one launch path alone fails. |
| Only when resuming a conversation | Compare starting the CLI with resuming the saved conversation | You know whether the problem is general terminal input or specific to resume. |
The message does not say your account quota ran out. It also differs from command not found: here Codex has started far enough to check its input stream.
Fixes, by branch
If you are running a script or pipeline
Use the documented non-interactive entry point, codex exec, instead of asking an unattended process to open the interactive interface. For example, in an already configured project directory:
codex exec --sandbox read-only "Summarize this project's README without changing files."
This runs a real model task and may consume usage. Use a project and account you intend to run it against. Authentication and project prerequisites still apply; a different error after this change needs its own diagnosis.
If a program supplies the entire prompt through standard input, the documented entry point is codex exec -. If you supply a prompt argument as well, piped input becomes additional context. Check which behavior your wrapper expects before changing it.
Expected result: the job produces a response without trying to start the interactive terminal interface. Do not enable broader filesystem permissions to solve a terminal-input error.
If you want an interactive conversation
Open your normal terminal and launch the same installed Codex directly, without a pipeline or input redirection. Compare this with the failing launcher. This is a diagnostic comparison, not a guarantee that a different terminal will fix the problem.
If direct launch works, inspect how the wrapper supplies standard input and whether it allocates a terminal. Keep the same executable and environment during the comparison; otherwise you may be comparing different installations.
If direct launch also fails, record the CLI version, shell, terminal application, and exact command. Repeated reinstallations do not establish which input handle Codex received.
If PowerShell is interactive but resume still fails
A Windows report describes this exception on CLI 0.116.0. The reporter also tried --no-alt-screen without resolving it, so that flag is not presented here as a fix.
Compare a fresh interactive launch with the resume operation. If only resume fails, preserve the saved conversation and use the resume troubleshooting guide for the next checks. Do not delete session history as a terminal-detection experiment.
How to tell it worked
For interactive use, the terminal interface must open and accept input. For automation, the intended task must complete through non-interactive mode. A successful help command alone does not test either path.
If it still fails
Record the exact error, CLI version, operating system, terminal and shell, launch command, and whether stdin came from a pipe. Include the direct-launch comparison and whether resume alone fails. Remove credentials and private prompt content before sharing logs.
Limits of this guidance
The source check explains where the error originates; it does not diagnose every wrapper or terminal. The Windows report is historical evidence, not proof that your installed version has the same defect. There is no verified fix version in this guide.
Sources
Each source lists what it is used to support. Sources are re-read on the review schedule, not continuously.
Codex TUI terminal initialization source
The init function checks stdin().is_terminal() and returns the exact error if the check fails. This is current source, not a release-specific reproduction.
codex exec is the documented automation entry point. It accepts piped context with a prompt argument, or codex exec - when stdin supplies the prompt; read-only sandbox behavior is documented.
Windows PowerShell resume reports stdin is not a terminal
One reporter on CLI 0.116.0 and Windows reports resume failing inside interactive PowerShell, including with --no-alt-screen. No verified fix is supplied by this article.
Related guides
How this page is checked
- Evidence level
- Reported - based on public reports, not reproduced here
- Last reviewed
- 2026-09-21
- Content updated
- 2026-09-21
- Full version scope
- The current TUI source checks whether stdin is a terminal. A separate Windows PowerShell report concerns CLI 0.116.0; it does not establish a regression in every release or a fixed version.
- Symptoms indexed
-
- Codex exits before showing its interactive terminal interface
- A wrapper or pipeline launches Codex without a terminal input stream
- An interactive PowerShell resume command returns the same error
Reviewer note
The terminal check and automation entry point were read in first-party sources. The Windows exception is a user report. No terminal failure was reproduced locally and no universal workaround or fixed version is claimed.