Skip to content

Implement a default timeout and provide feedback for shell commands #4775

@coygeek

Description

@coygeek

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:

  1. The child process should be terminated.
  2. A history event should be displayed in the TUI, indicating that the command timed out (e.g., • Ran command [timed out after 60s]).
  3. 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:

  1. I ask the agent to perform a task, for example, "install dependencies for this project."
  2. The agent decides to run npm install.
  3. The command hangs due to a network issue or a problematic package script.
  4. 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+C out of the entire session.

Desired Experience:

  1. Same prompt as above.
  2. The agent runs npm install.
  3. The command hangs.
  4. After the default timeout (e.g., 120 seconds), the command is killed.
  5. The TUI displays a message like: • Ran npm install [timed out after 120s].
  6. The agent receives an error result for its tool call and can then reason about the failure, perhaps trying npm install --verbose or 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions