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.rsin 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
commandcontainsgitas a word. A path like~/git/xcounts;digitandgitleaksdo not. - response
- The hook’s
updatedInputanswer for this Bash call, orNoneto leave it alone. Every other field the model set is carried through, asupdatedInputreplaces the whole input. - response_
from_ env responsewith the default read from this process’s environment (the CLI’s, which it inherits).- stopped_
at_ timeout - Whether the CLI may stop
commandat the timeout rather than move it to the background. - timeout_
for - The timeout this call should have, or
Noneto leave it as it is. - timeout_
of 🔒 - The call’s
timeoutin ms, when it sets one.