Expand description
A Bash call that runs long goes to the background, so the agent is free to take the next message.
Claude Code moves a Bash call to the background by itself when it has run past its timeout, gives
the model the tool result (“Command did not complete within its Ns timeout and was moved to the
background”) and ends the turn; the command’s end arrives later as a task notification that
starts a turn. That needs no terminal: it holds in AgentMux’s hosting (stream-json, no PTY). The
timeout is the CLI’s own BASH_DEFAULT_TIMEOUT_MS when the model sets none; the dock already
promotes a call at the same age (TOOL_PROMOTION_MS, frontend/app/agent-model/tool-adapter.ts).
Only the default is set, not BASH_MAX_TIMEOUT_MS. The CLI does not background a command that
contains git (or starts with sleep): it stops it at the timeout. With the maximum at the same
age, a git push, a clone or a commit with slow hooks would be stopped at that age whatever
timeout the model asked for. A timeout the model sets itself is the PreToolUse hook’s to
shape (agentmux-bashwrap, bash_timeout.rs): it clamps a longer one to the default so the call
goes to the background too, and leaves it alone for the commands the CLI stops at the limit, which
it also gives five minutes when the model set none.
Constants§
- BACKGROUND_
AFTER_ MS - How long a Bash call may run before it goes to the background.
Functions§
- apply
- Set the default Bash timeout in a launch environment: a Claude agent’s only. A value the
environment already carries (the agent’s own
cmd:env) is kept, so an operator can still choose otherwise;after_msof0sets nothing. - apply_
for_ spawn applyfor a block’s launch, reading the provider from its meta. A block with no provider is a Claude one, as elsewhere in the launch code.