Skip to content

fix: use temp file for large prompts instead of CLI args - #101

Merged
c-h- merged 1 commit into
mainfrom
fix/large-prompt-crash
Mar 5, 2026
Merged

c-h- merged 1 commit into
mainfrom
fix/large-prompt-crash

Conversation

@c-h-

@c-h- c-h- commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • When combined --spec/--file content exceeds ~100KB, the prompt inlined into CLI arguments can hit OS argv limits (ARG_MAX), causing the child process to crash silently on launch
  • For prompts exceeding the threshold, writes to a temp file and passes the file descriptor as stdin to the spawned process instead of including the prompt in the argument list
  • Small prompts continue to use CLI args for backward compatibility
  • All five adapters (claude-code, opencode, codex, pi, pi-rust) are updated with the same pattern

Fixes #98.

Test plan

  • npm run typecheck passes
  • npm test — all 466 tests pass
  • New unit tests for isLargePrompt, writePromptFile, openPromptFd, cleanupPromptFile
  • New integration tests verifying each adapter omits large prompts from CLI args and uses stdin fd instead
  • Manual test: agentctl launch opencode --spec <large-file> --file <file1> --file <file2> with >100KB combined content

🤖 Generated with Claude Code

Co-Authored-By: Charlie Hulcher [email protected]

When combined --spec/--file content exceeds ~100KB, the prompt inlined
into CLI arguments can hit OS argv limits (ARG_MAX), causing the child
process to crash silently on launch.

For prompts exceeding the threshold, write to a temp file and pass the
file descriptor as stdin to the spawned process instead of including the
prompt in the argument list. Small prompts continue to use CLI args for
backward compatibility.

All five adapters (claude-code, opencode, codex, pi, pi-rust) are
updated with the same pattern.

Fixes #98.

Co-Authored-By: Charlie Hulcher <[email protected]>
@c-h-
c-h- force-pushed the fix/large-prompt-crash branch from 4f2c76f to 132871d Compare March 5, 2026 22:52
@c-h-
c-h- merged commit 6cf3976 into main Mar 5, 2026
1 check passed
c-h- added a commit that referenced this pull request Mar 6, 2026
New features:
- feat: add --file flag to launch command (#95)

Bug fixes:
- fix: insert -- separator before positional prompt args (#106)
- fix: peek/status timeout on opencode sessions (#100)
- fix: use temp file for large prompts instead of CLI args (#101)

Performance:
- perf: use history.jsonl for Claude Code discover(), batch lsof calls (#96)

Co-Authored-By: Charlie Hulcher <[email protected]>
@c-h- c-h- mentioned this pull request Mar 6, 2026
c-h- added a commit that referenced this pull request Mar 6, 2026
New features:
- feat: add --file flag to launch command (#95)

Bug fixes:
- fix: insert -- separator before positional prompt args (#106)
- fix: peek/status timeout on opencode sessions (#100)
- fix: use temp file for large prompts instead of CLI args (#101)

Performance:
- perf: use history.jsonl for Claude Code discover(), batch lsof calls (#96)

Co-authored-by: Doink (OpenClaw) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: --spec/--file flags crash opencode sessions on large prompts

1 participant