run_bash tool so an autonomous agent can run shell commands on the terminal.
When to use it
- The agent needs to run CLI commands (e.g.
ls,python script.py,git status). - You use
max_loops="auto"and want the agent to have terminal access. - You want to keep other tools restricted and only add bash execution.
Enable the tool
Include"run_bash" in selected_tools when creating the agent:
Run a task
The agent will plan and callrun_bash when it needs to run a command:
Tool parameters
Commands run in the Python process’s current working directory, not the agent workspace. The tool returns the exit code, stdout and stderr. Long-running commands should use a higher
timeout_seconds or be avoided.
Limits and safety checks
- Length: commands over 512 characters are refused. If the command is a heredoc or redirect, the refusal tells the model to write the file with
create_fileorupdate_fileinstead, so give the agent those tools when it needs to write files. - Blocklist: commands matching dangerous patterns are refused, including recursive
rm, piping into a shell or interpreter,sudo, shutdown and reboot,printenv,curl -d, redirects into/etcor/usr, and redirects to disk devices or/dev/null. - Output cap: the result is capped at a quarter of the agent’s
context_lengthin tokens, with a marker saying how much was cut. Setcontext_lengthlower for a tighter cap. - Searches: for finding files or matching text, the
globandgreptools are preferred overfindandgrepthrough bash.
Example file
A starting-point script is in the repo. It builds this agent and prints the available tool names; uncomment theagent.run(...) call to run a task:
See also
- Autonomous Looper Tools – Configuring
selected_tools - Autonomous Mode – How the loop plans, runs tools and stays bounded
- Agent Reference –
selected_toolsand autonomous loop