Repository navigation
Done
Description
Poisoned resume loop on opencode driver: synchronously-rejected prompt replays forever
Two threads on the opencode driver (cliproxy-responses/opencode-go/muse-spark-1.3-contributor) entered a deterministic Error loop:
9024a170: run 27 executed tool calls, then at pos 45394 the model emitted an empty shell call ($ {}, rejected asInvalid arguments for tool shell: command: Missing key). Runs 27/28 then fail withThe request contains invalid parameters. Check the request body for any errors or inconsistencies.03930c66: run 29 completed (prod deploy verified), then/goal resumerun 30 fails in ~0.25s withThe provider could not start this turn. Retry the turn; if it keeps failing, check the provider setup and server logs.
Both fail at turn start with zero assistant/tool activity. Retry and /goal resume replay the identical payload and fail identically.
T3-side gaps found (this repo)
packages/provider-opencode/src/server/adapter.ts:2869-2871(v1) rejects empty prompts, butpackages/provider-opencode/src/server/v2/adapter.ts:2977-2986promptTextonly.trim()s with no empty guard. The v2submitatv2/adapter.ts:3284-3343sendssession.promptwith whatever text results.v2/adapter.ts:533-539CLEAR_PROMPT_REJECTIONS(InvalidRequestError,CommandNotFoundError, ...) skipsmarkUnsettled, so no prompt was admitted — butresumeThread(v2:3445-3469) only doessession.get+writeRules, never reverting/clearing the poisoned native state. Next attempt rebuilds the byte-identical payload (submithas no rewrite/strip of control text, no empty check), so a synchronous admission rejection loops forever, surfaced viaProviderAdapterTurnStartError->packages/provider-core/src/server/failure.ts:46-49.- The model-emitted empty
shell {}args are never validated before submission; the harness/gateway schema rejection is the first gate.
Evidence that the strings are external
Invalid arguments for tool shell,Check the request body,Missing keyhave zero hits underpackages/.InvalidRequestErrorappears only as a set member inv2/adapter.ts:534. Both messages come from the OpenCode CLI/server admission path or the upstream model gateway, forwarded by T3.
Suggested fix
- Add the v1 empty-prompt guard to v2
submit/promptText. - Before retry/resume after a
CLEAR_PROMPT_REJECTIONSfailure, sanitize or rewrite the payload (or surface a resumable state instead of replaying byte-identical input). - Optionally validate assistant tool-call args client-side so an empty
shell {}fails the turn with a retriable message instead of poisoning the native session.
Repro
On an opencode-driver thread, submit a turn whose prompt (or slash-command path) the OpenCode server rejects synchronously at admission, then retry or send /goal resume. The turn fails at start every time with no recovery path except fork.
Metadata
Metadata
Assignees
Labels
No labels
Activity
juliusmarminge commentedon Nov 24, 2026
@ImBIOS Which OpenCode version is T3 Code running (the version shown in Settings → Providers → OpenCode, or
opencode --version), and what error do the T3 Code server logs show for one of the failing turns (the error tag and the message OpenCode returned)?ImBIOS commentedon Nov 26, 2026
Running OpenCode v2.4.1 (matches Settings → Providers → OpenCode, and
opencode --version; T3 server0.1.12-nightly.20261123.5165).From
~/.local/share/opencode/log/opencode.logfor the failing turns:9024a170runs 27/28 (ses_e2cea4418ffeGjBBLkTDt1v5Ic): tagAI.Error.InvalidRequest, message "The request contains invalid parameters. Check the request body for any errors or inconsistencies." (Failed to drain SessionatSessionStep.attempt → SessionRunner.drain). T3 surfaces it ascode: "provider.invalid-request"with the same message.03930c66run 30 (/goal resume,ses_df95ebd17ffeYsOg5U5CPAPQTw): noAI.Error— insteadcommand execution failed ... command=goal error="Error: No paused goal to resume."withPOST /api/session/.../command → HTTP 500.