Home / Blog / Pricing

Pricing

Codex CLI "stdin is not a terminal": Why It Happens and How to Fix It

Codex CLI says 'stdin is not a terminal'? Why interactive commands fail in scripts, CI and PowerShell, and the non-interactive route OpenAI documents, sourced.

8 min read

Error strings checked Nov 2, 2026 in Codex GitHub issues #15886 and #54892 and pull request #6382. Commands and flags checked the same day in OpenAI’s non-interactive mode docs, CLI reference and CLI install page. Every source is listed at the bottom. No affiliate links on this page (how we work).

The exact error: stdin is not a terminal

You’ll see it in one of three shapes, depending on the command and version:

stdin is not a terminal
Error: stdin is not a terminal
ERROR: stdin is not a terminal

The first is from #15886, where codex resume --last failed in Windows PowerShell on Codex CLI v0.116.0. The second and third are from #54892: codex resume <id> </dev/null printed Error:, codex agents </dev/null printed ERROR:, and both exited with code 1 on codex-cli 0.163.0 (all verified Nov 2, 2026).

The short answer (as of Nov 2, 2026): you started an interactive Codex command, the full-screen terminal UI, without a real terminal on its input. Pipes, CI jobs, cron, </dev/null and some wrapper scripts all look like that to Codex. The fix is a real terminal for interactive work, and codex exec for everything automated.

This isn’t a crash. It’s a guard OpenAI added on purpose. Pull request #6382, “fix(tui): Fail when stdin is not a terminal”, was merged on Nov 21, 2025. Its description is refreshingly blunt: “Piping to codex fails to do anything useful and locks up the process. We currently check for stdout, but not stdin.” So instead of a frozen process, you get a one-line refusal. Fair trade, even if the message doesn’t tell you what to do next.

Where it shows up

Scripts, CI and pipes. Running codex with no subcommand “launches the interactive terminal UI (TUI)”, per the CLI reference. A TUI needs a keyboard on the other end. Pipe something into it (echo foo | codex, the example in PR #6382), run it from a CI step or redirect stdin from /dev/null, and nobody is there to type. It’s Cast Away for software: the TUI is ready to chat, and the only thing on the other end is a volleyball named Wilson.

Session commands: codex resume and codex agents. The CLI reference describes codex resume as the way to “Continue an interactive session”. #54892 (opened Oct 17, 2026) shows both codex agents and codex resume <id> refusing to run without a TTY. Its author notes that codex queue --thread <id> --message <text> does work without one. The issue is a feature request for a scriptable session list (codex agents --json or codex resume --list). That command didn’t exist on Nov 2, 2026, so don’t go looking for it.

Windows PowerShell, even when you’re sitting right there. This is the annoying one. In #15886 (opened Mar 26, 2026), a user in a normal, interactive PowerShell window got stdin is not a terminal from codex resume --last and codex resume --last --no-alt-screen. They said codex --help worked and the shell wasn’t WSL or a VS Code terminal, and suggested a Windows TTY detection issue. The issue was open with no official reply as of Nov 2, 2026, so that diagnosis is the reporter’s, not OpenAI’s. Being told you’re not in a terminal while staring at one is a very Lost in Translation feeling: right place, and still nobody understands you.

Fixes

1. Interactive work: run it in a real terminal. If you meant to use the TUI, open a terminal window and run codex or codex resume there, not through a pipe, task runner or script wrapper. If a tool like just or make wraps the call, run the command directly to check whether the wrapper is eating stdin.

2. Automation: use codex exec. OpenAI’s docs are clear on this: “Non-interactive mode lets you run Codex from scripts (for example, continuous integration (CI) jobs) without opening the interactive TUI. You invoke it with codex exec” (verified Nov 2, 2026). The basics:

codex exec "summarize the repository structure and list the top 5 risky areas"
  • Progress streams to stderr, and only the final agent message goes to stdout, so you can pipe or tee the result.
  • Piping is fine here. “If stdin is piped and you also provide a prompt argument, Codex treats the prompt as the instruction and the piped content as additional context.” Use codex exec - when stdin should be the whole prompt.
  • --json turns stdout into a JSON Lines event stream. -o <path> writes the final message to a file. --output-schema asks for JSON that matches a schema.
  • The default sandbox is read-only. Use --sandbox workspace-write to allow edits. OpenAI says to use danger-full-access “only in a controlled environment (for example, an isolated CI runner or container)”.
  • --full-auto “is no longer supported”. If an old script uses it, switch to --sandbox workspace-write.
  • Codex wants a Git repository. --skip-git-repo-check overrides that only “if you’re sure the environment is safe”.

3. Resuming from a script: use codex exec resume. This is the direct fix for the codex resume case in automation. The docs show a two-stage pipeline:

codex exec "review the change for race conditions"
codex exec resume --last "fix the race conditions you found"

You can also target a specific run with codex exec resume <SESSION_ID>. Per the CLI reference, --last picks the most recent session from the current working directory, and --all searches across all sessions.

4. CI authentication. OpenAI’s guidance is to set CODEX_API_KEY only for the single Codex invocation that needs it, and not as a job-level variable in workflows that run repository code. On GitHub Actions, it points you to the openai/codex-action instead of installing the CLI yourself (non-interactive docs, verified Nov 2, 2026).

5. Update the CLI. The PowerShell report is on v0.116.0, an older build. Install-page update commands (verified Nov 2, 2026):

InstallUpdate command
macOS/Linuxcurl -fsSL https://chatgpt.com/codex/install.sh | sh
Windowspowershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
npmnpm install -g @openai/codex
Homebrewbrew upgrade --cask codex

The CLI reference also lists codex update for builds that support self-update, and codex doctor, a diagnostic report that checks installation, configuration, authentication and the terminal. A merged pull request, #44615, shows the doctor’s terminal check knows about runs where neither stdin nor stdout is a terminal. If PowerShell still refuses after updating, run codex doctor, then add your details to #15886.

What I wouldn’t do: fake a TTY with wrapper tricks to force the TUI to run inside CI. OpenAI built codex exec for that job, with sandbox flags and machine-readable output. Forcing an interactive UI into a pipeline gets you exactly the locked-up process PR #6382 was written to prevent.

Interactive vs non-interactive commands

CommandNeeds TTYUse in CI
codexYesNo
codex resumeYesNo, use exec resume
codex agentsYes (#54892)No
codex execNoYes
codex exec resumeNoYes
codex cloud listNoYes, with —json

“Needs TTY” for codex and codex resume comes from the CLI reference’s “interactive” wording and the errors in #15886 and #54892; for codex agents it comes from #54892. The exec rows and codex cloud list (“for scripting”, --json) come from OpenAI’s non-interactive docs and CLI reference, verified Nov 2, 2026.

Not the same as other Codex errors

stdin is not a terminal is local. It has nothing to do with your plan, your usage or OpenAI’s servers, and paying more won’t change it. If Codex drops mid-response, that’s Codex stream disconnected. If you’ve run out of allowance, see Codex usage limits. For plans: Is Codex free? and Codex pricing. Comparing CLIs? AI coding tools compared has dated prices.

Here’s what I’d do

If it happened in a script or CI: replace codex with codex exec "<task>", and codex resume with codex exec resume --last "<next step>". Add --sandbox workspace-write only if it needs to edit files. Done. If it happened in a real PowerShell window: update the CLI, run codex doctor, and if resume still refuses, comment on #15886 with your version. It’s a tooling bug, and the people who can fix it read that issue. My one gripe: an error that says what’s wrong but not what to run instead costs every team that hits it ten minutes. The #54892 author asked for a “requires a terminal” hint. They’re right.

For the “Error submitting message” failure in the Codex app and extension, see the Codex error submitting message fix.

FAQ

What does stdin is not a terminal mean in Codex CLI? An interactive Codex command (the TUI, resume or agents) was started without a real terminal on its input, such as from a pipe, script or CI job.

How do I run Codex CLI in CI? Use codex exec with a prompt, set the sandbox you need (read-only by default), and on GitHub Actions use the openai/codex-action.

How do I resume a Codex session from a script? Use codex exec resume —last "" or codex exec resume <SESSION_ID> instead of codex resume.

Does stdin is not a terminal affect Windows only? No, it appears anywhere stdin isn’t a terminal, but #15886 reports it in an interactive Windows PowerShell window too.

Will upgrading my ChatGPT plan fix it? No, it’s a terminal check in the CLI and has nothing to do with plans or usage limits.

Can I pipe input into Codex at all? Yes, with codex exec: piped content becomes context for your prompt, or codex exec - reads the whole prompt from stdin.

Sources

  1. Codex GitHub issue #15886 (stdin is not a terminal, codex resume —last, Windows PowerShell, v0.116.0): https://github.com/openai/codex/issues/15886 (verified 2026-11-02)
  2. Codex GitHub issue #54892 (Error:/ERROR: stdin is not a terminal, codex agents and codex resume, exit 1, codex queue works without TTY): https://github.com/openai/codex/issues/54892 (verified 2026-11-02)
  3. Codex pull request #6382 (fix(tui): Fail when stdin is not a terminal, merged Nov 21, 2025): https://github.com/openai/codex/pull/6382 (verified 2026-11-02)
  4. Codex pull request #44615 (codex doctor terminal check for non-interactive runs): https://github.com/openai/codex/pull/44615 (verified 2026-11-02)
  5. OpenAI Codex non-interactive mode (codex exec, stdin piping, sandbox, —json, -o, —output-schema, exec resume, CODEX_API_KEY, codex-action, Git check): https://developers.openai.com/codex/noninteractive (verified 2026-11-02)
  6. OpenAI Codex CLI reference (TUI, codex exec, codex resume, codex cloud list, codex doctor, codex update): https://developers.openai.com/codex/cli/reference (verified 2026-11-02)
  7. OpenAI Codex CLI install and update commands: https://developers.openai.com/codex/cli (verified 2026-11-02)

Related reading