Skip to content

opencode: send the side-call prompt on stdin, not the command line - #244

Open
Have-Purple wants to merge 1 commit into
microsoft:mainfrom
Have-Purple:fix/opencode-sidecall-stdin
Open

Have-Purple wants to merge 1 commit into
microsoft:mainfrom
Have-Purple:fix/opencode-sidecall-stdin

Conversation

@Have-Purple

Copy link
Copy Markdown

The proposer's prompt — eight task digests plus the facts — is about 35,000 characters on a
real install, and Windows stops a command line at 32,767: CreateProcess fails with
ERROR_FILENAME_EXCED_RANGE, which Python raises as

FileNotFoundError: [WinError 206] The filename or extension is too long

The whole prompt was passed as the last argv element, so as soon as the window plus the fact list
grew past the limit, every proposer tick failed: no session was created, the tick was skipped
and logged, and micro-skills ran on the free env-facts layer alone. The log line is the one above,
repeated per fold.

Change

opencode run reads the message from stdin when it is given none, so the prompt goes there:

out = subprocess.run([*exe, "run", *opencode_flags(cli), "--format", "json", *model_args],
                     input=prompt, capture_output=True, encoding="utf-8",
                     errors="replace", timeout=timeout, env=env, cwd=cwd)

--model and the other flags are unchanged; the session-delete call is unchanged.

Verification

  • Reproduced the failure without a model: a 32,000-character argument starts, 33,000 raises
    the same FileNotFoundError: [WinError 206].
  • End to end on opencode 2.3.0, against a local OpenAI-compatible endpoint (no model billed):
    a 48,000-character prompt through sidecall.opencode_call returns the model's reply
    (done, 106 effective tokens), and the prompt arrives at the endpoint intact.
  • Same call, unmodified main (583fff7): FileNotFoundError [WinError 206].
    The 48,000-character prompt is the same one; only the argv/stdin placement differs.
  • Unit tests: a 48,000-character prompt never appears on argv and is passed as input=; the
    existing placement test now expects opencode's prompt on stdin. Full offline suite:
    1168 passed, 35 skipped, 0 failed.

Scope

opencode only, and deliberately: other hosts also put the prompt on argv, but each has its own
CLI contract and this was the host whose calls were failing. claude_call already passes the
prompt via input=.

The proposer's prompt -- eight task digests plus the facts -- is about 35,000 characters on this
install, and Windows stops a command line at 32,767: CreateProcess failed with WinError 206
before any session existed, so every proposer tick was skipped (and logged) once the prompt
crossed the limit, and micro-skills ran on the free layer alone.

`opencode run` reads the message from stdin when it is given none. Verified on opencode 2.3.0
against a local OpenAI-compatible endpoint: a 48,000-character prompt arrives intact and the
reply comes back, where the argv form raises FileNotFoundError WinError 206 on the same prompt.
The `--model` and other flags are unchanged.

Tests: a 48,000-character prompt never appears on argv and is passed as `input=`; the
placement test now expects opencode's prompt on stdin rather than in the command.
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.

1 participant