The bash agent
The basic agent works, but it's fragile. What happens if the model runs rm -rf /? What if a command takes forever? What if the output is 100MB? The safety rails phase adds the limits that make an agent usable in practice.
Bash tool safety layers
Every bash command passes through three safety checks before execution.
The safety rails phase also adds dual-mode operation. Run it interactively as a REPL, or pass a query via sys.argv for one-shot subagent mode. This pattern is how Claude Code launches subagents: same script, different entry point. The process calls itself recursively.
Quiz: Quiz
Loading practice…
Terminal
bash
# Run the bash agent
make 02-bash-agent
# Try dangerous commands -- they get blocked
# Try: "Run rm -rf /" (will be blocked)
# Try: "Find all Python files in this directory"Test the safety rails. Dangerous commands are blocked, timeouts are enforced.