fix: pass prompt via stdin to avoid "Argument list too long" on large PRs#35
Merged
Conversation
… PRs Both run_opencode and run_gemini passed the full prompt as a single argv argument (`opencode run -m M "$(cat prompt)"` / `gemini --prompt "$(cat prompt)"`). On Linux the per-argument cap is MAX_ARG_STRLEN = 128KB; a PR with a large diff produces a 150KB+ prompt, so the exec fails with "Argument list too long" (exit 126) and validation hard-fails before the model ever runs. Feed the prompt through stdin instead — neither CLI has a per-arg limit on a piped stream: - opencode reads a non-TTY stdin as the message (packages/opencode/src/cli/ cmd/run.ts: `process.stdin.isTTY ? undefined : await Bun.stdin.text()`). - gemini reads a non-TTY stdin as the prompt (packages/cli/src/gemini.tsx: `!process.stdin.isTTY` → readStdin() → pushed as --prompt); --prompt is also deprecated upstream. `set -o pipefail` (already enabled) keeps $? as the CLI's exit code through the `| tee` pipe, so retry/exit-code handling is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
run_opencodeandrun_geminipass the entire prompt as a single argv argument:On Linux the per-argument cap is
MAX_ARG_STRLEN= 128 KB (PAGE_SIZE × 32). A PR with a large diff produces a 150 KB+ prompt, so the kernel rejects the exec withArgument list too long(exit 126) and validation hard-fails before the model is ever invoked.Observed in the wild on a large PR (179 KB prompt):
Fix
Feed the prompt through stdin instead. A piped stream has no per-argument size limit. Verified both CLIs read a non-TTY stdin as the prompt directly from their source:
packages/opencode/src/cli/cmd/run.ts:const piped = process.stdin.isTTY ? undefined : await Bun.stdin.text()→ used as the message when no positional arg is given.packages/cli/src/gemini.tsx:if (!process.stdin.isTTY) stdinData = await readStdin()→ pushed as--prompt. (--promptis also deprecated upstream, so this drops a deprecation too.)set -o pipefailis already enabled, so$?still reflects the CLI's exit code through the| teepipe — retry detection and exit-code handling are unchanged.Testing
bash -n scripts/validate.sh— syntax clean.Argument list too longat exec on Linux, while the same payload over< filestdin has no limit.| tee), retry loop, and exit-code semantics are identical.🤖 Generated with Claude Code