-
Couldn't load subscription status.
- Fork 6k
Description
What feature would you like to see?
I would like to request the implementation of a default timeout for all shell commands executed by the agent. When a command runs longer than this timeout, it should be terminated, and both the user and the agent should receive feedback that a timeout occurred.
Currently, if the agent runs a shell command that hangs, crashes in a weird way, or is simply long-running without the model specifying a timeout_ms, the CLI appears to freeze. The user is left with a "Working..." spinner indefinitely, with no indication of what's happening or a clear way to proceed besides killing the entire process.
A default timeout (e.g., 60 or 120 seconds) would act as a crucial safety net, ensuring that the agent can recover from stuck processes and the user is always kept in the loop.
When a timeout is hit:
- The child process should be terminated.
- A history event should be displayed in the TUI, indicating that the command timed out (e.g.,
• Ran command [timed out after 60s]). - An error/timeout result should be sent back to the model so it can attempt to recover, try a different approach, or inform the user.
Additional information
This feature is standard in other agentic coding tools. For example, Claude Code has a BASH_DEFAULT_TIMEOUT_MS environment variable that provides this exact safety net. Its absence in Codex CLI is a noticeable gap in user experience and agent robustness.
Current Experience with Codex CLI:
- I ask the agent to perform a task, for example, "install dependencies for this project."
- The agent decides to run
npm install. - The command hangs due to a network issue or a problematic package script.
- The Codex TUI shows the spinner and "Working..." indefinitely. I have no idea if it's making progress or if it's completely stuck. My only recourse is to
Ctrl+Cout of the entire session.
Desired Experience:
- Same prompt as above.
- The agent runs
npm install. - The command hangs.
- After the default timeout (e.g., 120 seconds), the command is killed.
- The TUI displays a message like:
• Ran npm install [timed out after 120s]. - The agent receives an error result for its tool call and can then reason about the failure, perhaps trying
npm install --verboseor notifying me of the issue.
While the shell tool does have a timeout_ms parameter, the model does not and cannot be expected to proactively add a timeout to every single command it runs. A global default timeout would make the agent much more resilient and provide a significantly better user experience by preventing indefinite hangs.