Repository navigation
fix(agents): give opencode its prompt on stdin, not as an argument - #466
Merged
Merged
Conversation
aidan-sims
force-pushed
the
aidan/fde-2585-opencode-prompt-stdin
branch
from
November 3, 2026 15:47
d070c45 to
e979766
Compare
aidan-sims
marked this pull request as ready for review
November 3, 2026 16:08
aidan-sims
force-pushed
the
aidan/fde-2585-opencode-prompt-stdin
branch
from
November 3, 2026 16:26
e979766 to
d543b8a
Compare
earakely-scale
approved these changes
Nov 4, 2026
Base automatically changed from
aidan/fde-2584-builtin-tools-codex-opencode
to
main
November 4, 2026 16:25
run_opencode passed the whole prompt as one argv element, and Linux caps a single argument at 128 KiB (MAX_ARG_STRLEN), so a longer prompt failed exec with E2BIG before the CLI started. opencode-ai 1.17.18 reads stdin when it isn't a TTY, so the prompt (with its output-format suffix) now goes there, fed while stdout is read and tolerating a CLI that exits before reading it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Covers first and resumed turns, a 1 MiB prompt with its output-format suffix, a real exec of a 1 MiB prompt (E2BIG on main), and a CLI that exits without reading its stdin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… its errors fail the turn Two regression guards for the stdin hand-off: a real CLI that fills its stdout and stderr pipes before reading a 1 MiB prompt must not deadlock the turn, and a prompt write that fails with anything other than a closed pipe must raise rather than report success. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aidan-sims
force-pushed
the
aidan/fde-2585-opencode-prompt-stdin
branch
from
November 4, 2026 16:26
d543b8a to
71ba171
Compare
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.
Owner: Aidan Sims. Ticket: FDE-2585. Builds on #465 (builtin_tools, merged), which touched the same file.
run_opencodepassed the whole prompt as a single argv element. Linux caps one argument at 128 KiB (MAX_ARG_STRLEN), so a longer prompt failed exec with E2BIG before the CLI started. opencode-ai 1.17.18 reads stdin when it isn't a TTY, so the prompt, including its output-format suffix, now goes there.stdin=PIPE, and_stream_clifeeds the prompt in a task that runs while stdout is read. This avoids a deadlock when the CLI prints before it has read all of its input.Validation:
uv run pytest tst/unit/agents/opencodegives 119 passed, 7 skipped (Linux-only); its two builtin_tools tests now read the prompt from stdin. New tests cover first and resumed turns, a 1 MiB prompt, a real exec of a 1 MiB prompt (E2BIG on main), a CLI that exits without reading stdin, a real CLI that writes 300 KB to stdout and stderr before reading its prompt, and a write error that fails the turn. The last two were checked against mutants of the fix and fail on them.ruff checkpasses on the touched files.Not in this PR:
ruff format --checkon main.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
OpenCode prompts now travel through stdin instead of command arguments, avoiding the per-argument size limit.
Diagram
sequenceDiagram participant Bridge participant CLI as OpenCode CLI Bridge->>CLI: Start with piped stdin, stdout, and stderr par Feed prompt Bridge->>CLI: Write prompt and close stdin and Read events CLI-->>Bridge: Stream stdout events and Read errors CLI-->>Bridge: Stream stderr end Bridge->>CLI: Wait for exit Bridge->>Bridge: Build turn resultReviews (3) · Last reviewed commit: "test(agents): the builtin_tools tests re..." · Reviewed by Greptile