Pi Coding Agent CLI Integration¶
Status: Accepted (Amends ADR 0005)
To provide developers with an interactive, terminal-native AI coding agent inside Modal Sandboxes alongside Antigravity, OpenCode, and T3 Code, we decided to integrate the Pi Coding Agent CLI (pi.dev) via a dedicated --pi launch flag, pre-configured with OpenCode Go and DeepSeek V4.1 Flash.
Considered Options¶
- Manual Interactive Setup in Sandbox Sessions: Requiring developers to run
curl -fsSL https://pi.dev/install.sh | bashand authenticate manually via/loginupon attaching over SSH or shell. Rejected because manual setup delays developer workflows, requires repeated credential re-entry across ephemeral sandboxes, and risks credential leaks in bash history. - Dynamic Startup Generation of Configuration: Generating
~/.pi/agent/settings.jsondynamically insidestartup.shvia inline bash heredocs. Rejected because dynamic scripts obscure agent configuration from version control and break declarative parity with existing shared tooling configs (shared/opencode.json,shared/antigravity-settings.json). - Declarative Staging of Shared Configuration with SOPS Decryption: Pre-baking the global CLI package (
@earendil-works/pi-coding-agent) via npm, tracking declarative agent configuration files (shared/pi-settings.jsonandshared/pi-models.json) in version control, and orchestrating ephemeral SOPS decryption ofsecrets/opencode.envduring container initialization. Accepted because it delivers instantaneous agent availability upon SSH attachment, maintains version-controlled configurations, and reuses established SOPS credential management.
Consequences¶
- CLI Flag (
--pi): Added tosandbox/cli.pyandsandbox/main.py. Mutual exclusivity with--snapshotis enforced. - Declarative Configuration:
shared/pi-settings.jsonsetsdefaultProvider: "opencode-go"anddefaultModel: "deepseek-v4.1-flash", staged to/root/.pi/agent/settings.json.shared/pi-models.jsonregisters theopencode-goprovider endpoint (https://opencode.ai/zen/go/v1) using$OPENCODE_GO_API_KEY, staged to/root/.pi/agent/models.json.- Image Layering (
shared/image.py): - Installs
@earendil-works/pi-coding-agentglobally via npm in the container filesystem. - Stages
LOCAL_PI_SETTINGS,LOCAL_PI_MODELS, andLOCAL_OPENCODE_SECRETinto the container image. - Lifecycle & Secrets (
shared/startup.shandscripts/setup.sh): - Passing
--pitriggerssetup.sh --pi, ephemerally decryptingsecrets/opencode.envwithAGE_PRIVATE_KEY. - Exports
OPENCODE_GO_API_KEYandOPENCODE_API_KEYinto~/.bashrcand/etc/environmentfor subshell and login shell availability. - Staged secrets in
/root/secrets/are scrubbed following decryption. - Domain Modeling: The canonical term Pi Coding Agent CLI is added to
CONTEXT.md. - Universal File Line Budget: All modified files remain strictly <= 500 lines.