Skip to content

Poisoned resume loop on opencode driver: synchronously-rejected prompt replays forever #41870

Done

Description

@ImBIOS

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 as Invalid arguments for tool shell: command: Missing key). Runs 27/28 then fail with The request contains invalid parameters. Check the request body for any errors or inconsistencies.
  • 03930c66: run 29 completed (prod deploy verified), then /goal resume run 30 fails in ~0.25s with The 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)

  1. packages/provider-opencode/src/server/adapter.ts:2869-2871 (v1) rejects empty prompts, but packages/provider-opencode/src/server/v2/adapter.ts:2977-2986 promptText only .trim()s with no empty guard. The v2 submit at v2/adapter.ts:3284-3343 sends session.prompt with whatever text results.
  2. v2/adapter.ts:533-539 CLEAR_PROMPT_REJECTIONS (InvalidRequestError, CommandNotFoundError, ...) skips markUnsettled, so no prompt was admitted — but resumeThread (v2:3445-3469) only does session.get + writeRules, never reverting/clearing the poisoned native state. Next attempt rebuilds the byte-identical payload (submit has no rewrite/strip of control text, no empty check), so a synchronous admission rejection loops forever, surfaced via ProviderAdapterTurnStartError -> packages/provider-core/src/server/failure.ts:46-49.
  3. 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 key have zero hits under packages/. InvalidRequestError appears only as a set member in v2/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_REJECTIONS failure, 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.

Activity

  1. juliusmarminge commented on Nov 24, 2026

    @juliusmarminge
    Member

    @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)?

  2. added
    needs more info
    on Nov 24, 2026
  3. ImBIOS commented on Nov 26, 2026

    @ImBIOS
    ContributorAuthor

    Running OpenCode v2.4.1 (matches Settings → Providers → OpenCode, and opencode --version; T3 server 0.1.12-nightly.20261123.5165).

    From ~/.local/share/opencode/log/opencode.log for the failing turns:

    • 9024a170 runs 27/28 (ses_e2cea4418ffeGjBBLkTDt1v5Ic): tag AI.Error.InvalidRequest, message "The request contains invalid parameters. Check the request body for any errors or inconsistencies." (Failed to drain Session at SessionStep.attempt → SessionRunner.drain). T3 surfaces it as code: "provider.invalid-request" with the same message.
    • 03930c66 run 30 (/goal resume, ses_df95ebd17ffeYsOg5U5CPAPQTw): no AI.Error — instead command execution failed ... command=goal error="Error: No paused goal to resume." with POST /api/session/.../command → HTTP 500.
  4. removed
    needs more info
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions