Skip to main content

Module bash_timeout

Module bash_timeout 

Source
Expand description

The timeout of a Bash call, set by the PreToolUse hook so the agent is free after 30 seconds.

AgentMux has Claude Code move a Bash call to the background once it has run for BASH_DEFAULT_TIMEOUT_MS (30 s), so the agent can take the next message. That default applies only to a call with no timeout of its own: a model that sets one (a build, a wait on the build slot) holds its turn for it. So the hook clamps a longer timeout to the default.

The CLI does not move every command to the background. A command it cannot parse into simple commands is stopped at the timeout instead (exit 143): one with git in it, a command or process substitution, a parameter, brace or $'...' expansion. Measured on 2.1.218; $VAR, ~, globs, loops, if, subshells, bash -c, eval, heredocs, redirects, pipes, &&, ; and & are moved. For a call of that kind the hook does the reverse and gives a timeout long enough to finish when the model set none; a timeout the model chose stands, as it did before the 30 s default. It answers updatedInput only, with no permission decision, so the user’s allow, ask and deny rules still apply to the call.

Constants§

DEFAULT_ENV 🔒
The CLI’s default Bash timeout, which AgentMux sets at launch (backend/bash_background.rs in srv).
LONG_TIMEOUT_MS
The timeout a call the CLI would stop gets when the model set none: long enough for a push or a clone.
STOPPED_SPELLINGS 🔒
Spellings that make the CLI stop a command at the timeout instead of moving it to the background. Wider than what was measured on purpose: a { alone, or one inside quotes, is also taken as one, so a call is clamped only when it is known to be moved.

Functions§

mentions_git
Whether command contains git as a word. A path like ~/git/x counts; digit and gitleaks do not.
response
The hook’s updatedInput answer for this Bash call, or None to leave it alone. Every other field the model set is carried through, as updatedInput replaces the whole input.
response_from_env
response with the default read from this process’s environment (the CLI’s, which it inherits).
stopped_at_timeout
Whether the CLI may stop command at the timeout rather than move it to the background.
timeout_for
The timeout this call should have, or None to leave it as it is.
timeout_of 🔒
The call’s timeout in ms, when it sets one.