The agent only knows what you let it see
Three knobs scope the agent's blast radius. cwd sets the working directory — Read/Write/Edit/Bash all run from there. env sets the environment variables visible to subprocess tools. Network access can be gated at the OS layer (firewall, VPN) or via your own MCP servers' policies.
Set cwd to the smallest viable directory
If the agent only needs to edit files under /srv/myapp, do not set cwd to /. The model will see paths relative to cwd, and the SDK will refuse paths that escape it (with default settings). Narrow cwd is half the sandbox.
Strip env to minimum
Bash inherits the env you provide. If you forward your full shell environment, the agent has access to every credential variable. Provide only what tools genuinely need: PATH, HOME, plus task-specific keys. Leak protection is mostly env protection.