OpenCode agent provider fails with spawn E2BIG for prompts over Linux argv limit
Description
The OpenCode agent provider fails with spawn E2BIG when a resolved prompt exceeds Linux's per-argument process limit. Sandcastle currently shell-escapes the full prompt into the positional opencode run command, so the process fails to spawn before OpenCode starts.
Reproduction
Minimal Docker-sandbox reproduction:
git clone https://github.com/zero-two-rafaeltab/sandcastle-opencode-e2big-repro.git
cd sandcastle-opencode-e2big-repro
git checkout 43d385175449ecfba54dc7683b7619a085e020c0
make reproduceThe reproduction uses a synthetic 150,000-byte ASCII inline prompt and exits with:
ExecError: exec failed: spawn E2BIGNo credentials are required and no model request is made.
Versions
Verified on 2026-08-29:
@ai-hero/sandcastle0.12.0 — the version in this repository and the current latest npm releaseopencode-ai1.18.25 — the current latest npm release- OpenCode model configuration:
openai/gpt-5.6-luna, variantlow - Linux with the Docker sandbox provider
Root cause
For the same 150,000-byte prompt, the built-in providers produce:
| Agent provider | Command bytes | Stdin bytes |
|---|---|---|
| OpenCode | 150,106 | 0 |
| Codex | 78 | 150,000 |
| Claude Code | 115 | 150,000 |
| Pi | 47 | 150,000 |
OpenCode places the prompt in the command; the other providers transport it via stdin.
On Linux, a single process argument reaches the boundary at 128 KiB:
131071 ok
131072 E2BIGThis is a process argument limit rather than an agent context-window error. Shell escaping may make the assembled command larger still.
Expected behavior
The OpenCode agent provider should transport prompts that are valid for the agent without failing at the operating-system argument boundary. A clearer preflight error would improve diagnostics but would not resolve the transport limitation.
Related issues
- #387 diagnosed the general Linux
MAX_ARG_STRLENfailure. - #393 moved another provider's prompt transport to stdin to fix #387.
- #703 introduced the current OpenCode provider behavior.
- #928 discusses prompt transport and shell-command expansion for Claude Code.
Source: mattpocock/sandcastle