Strands Agents documentation
ai-engineeringdev-tools
Original source

Strands Shell — Virtual Shell for AI Agents

Summary

Strands Shell 是一個 Bourne-compatible 的虛擬 shell,專為 AI agent 設計,跑在你自己的 process 裡面(不需要 container 或 cloud sandbox)。用 Rust 寫的,支援 Python (PyO3)、Node.js (napi-rs) 和 WASM。

核心特點:

  • 極快 — 啟動 + 執行命令 < 1ms(對比 Docker ~200ms,cloud sandbox ~1s)
  • In-process isolation — 用 VFS (virtual filesystem) + mediation layer 隔離,不用 fork/exec/syscall
  • 內建工具 — grep, sed, jq, curl, find 等常見指令都內建,不呼叫系統命令
  • Deny-by-default — 全新 shell 啟動時沒有任何存取權限(檔案、網路、credentials),需明確授予

三個控制機制:

  1. Binds — 把 host 目錄映射進 shell 的 VFS(copy bind = 快照隔離,direct bind = 即時讀寫)
  2. Credentials — 綁定 secret 到 URL prefix,請求時自動注入,agent 看不到 secret 本身
  3. Allowed URLs — 網路預設擋 RFC1918/loopback/cloud metadata,白名單放行特定 URL

不是什麼:

  • 不是 hardened sandbox — 是 mediation layer,跑在同一個 process
  • 對抗 adversarial code 仍需 OS-level isolation(container/microVM)
  • Resource limits 是 best-effort,不防主動攻擊者
  • 單一 owner 設計,多 agent 要各開一個 instance(建構成本極低)

比較表:

DockerCloud SandboxStrands Shell
Cold start~200ms~1s<1ms
IsolationContainer namespaceMicroVMIn-process VFS
NetworkiptablesPlatform policyURL allowlist + SSRF guard
SecretsEnv vars (agent可讀)Platform-specific按請求注入,agent不可讀
SetupDocker daemonAPI key + networkpip install strands-shell
PlatformsLinuxCloud onlymacOS, Linux, WASM