Skip to content

fix(tool): coi tool spec feeds claude the prompt on stdin, codex after -- - #1188

Merged
mensfeld merged 3 commits into
masterfrom
fix/56901-tool-spec-prompt-stdin
Dec 4, 2026
Merged

mensfeld merged 3 commits into
masterfrom
fix/56901-tool-spec-prompt-stdin

Conversation

@coipond-coder

@coipond-coder coipond-coder Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Redmine: 56901

coi tool spec (interactive launch, no print mode) still passed the prompt to claude and codex as a positional "$(cat <file>)", so a prompt starting with - (front matter ---, a list item - , --version) was parsed as tool options, and one of 128 KiB or more failed with Argument list too long. #1181 fixed this for the coi run --prompt (print-mode) path only.

  • claude: the command ends with <file. Interactive Claude Code reads a redirected stdin as the first message and then opens the terminal for the session. Checked with Claude Code 2.1.335 in tmux: a 200 KB prompt starting with --version arrived byte-exact in the transcript (200029 chars) and typed keys still reach the input box. No piped-input join here: the orchestrator's stdin is the terminal.
  • codex: interactive codex refuses a non-terminal stdin (Error: stdin is not a terminal, codex-cli 0.173.0), so the prompt stays a positional, now after -- (clap: codex -- --version opens the TUI instead of printing the version; also codex resume <id>|--last ... -- <prompt>). A prompt larger than one argument can hold (131071 bytes) can't go in the command at all: BuildCommandLaunch returns tool.ErrPromptOutOfBand, and the spec comes back without it and with the staged path in the existing prompt field, as for opencode, for the orchestrator to deliver after launch.

coi tool spec now passes the staged prompt's size in LaunchSpec.PromptSize. Help text updated.

Tests

  • internal/tool/launch_test.go: runs the rendered command through bash -c with a stub tool binary. Claude interactive: --version, - fix ..., front matter and 200 KiB arrive byte-exact on stdin, no prompt in argv. Codex: the dash prompts arrive as the argument after -- for a fresh launch, resume <id> and resume --last; a 131071-byte prompt runs, 131072 fails the exec with Argument list too long, and a larger PromptSize returns ErrPromptOutOfBand. These fail on master.
  • internal/cli/tool_spec_test.go: a 200 KiB codex prompt comes back out-of-band with no prompt in the command; claude/codex assertions updated.
  • e2e tests/config/test_tool_spec.py: assertions updated (<file for claude, -- "$(cat …)" for codex); the codex test also stages a 200 KiB prompt and expects the prompt field. Needs Incus: not run locally, CI only.

Local: go test -short -race ./..., go vet, gofmt, golangci-lint (0 issues), ruff check/ruff format --check.

Performance impact

none (launch-command construction, once per orchestrator launch; not a hot path).

…r --

A prompt starting with "-" was parsed as tool options, and one of
128 KiB or more failed with "Argument list too long". Interactive codex
refuses a non-terminal stdin, so a codex prompt too large for one
argument comes back out-of-band in the spec's prompt field.
@coipond-coder coipond-coder Bot added the bug Something isn't working label Dec 3, 2026
@coipond-coder
coipond-coder Bot marked this pull request as ready for review December 3, 2026 19:57
@coipond-coder
coipond-coder Bot requested a review from mensfeld as a code owner December 3, 2026 19:57
@mensfeld
mensfeld merged commit 9d7f1cb into master Dec 4, 2026
1 check passed
@mensfeld
mensfeld deleted the fix/56901-tool-spec-prompt-stdin branch December 4, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant