Skip to content

[Bug]: Native chat rejects every message when the selected model differs from the agent's current model — OpenCode 2 ACP has no session/set_model (root cause + verified fallback) #32183

Closed

Description

@yzyDavid

Operating system

macOS

Orca version

1.4.237

Details

Summary

In the Chat UI, any conversation whose selected model differs from the OpenCode agent's current model rejects every message immediately with OpenCode didn't accept this message. (rejection.kind = providerRejected). The default model works fine in the same setup. The prompt never reaches the agent or the model provider.

This is the same visible failure as #31475 and #31423, but with the actual root cause identified and a verified fix path.

Root cause

Orca writes the model option via the custom ACP method session/set_model (src/main/acp/acp-session-runtime.ts:224 on current main). The OpenCode v2 line does not implement that method — it returns JSON-RPC -32601 "Method not found": session/set_model. applyAcpMessageOptions (src/main/acp/acp-message-execution-options.ts:38-52) converts any setOption failure into AgentSessionOptionRejectedError, so the message is rejected before session/prompt is ever sent.

session/set_model exists in the OpenCode 1.x ACP implementation (cf. anomalyco/opencode#9941), but the v2 rewrite (latest release v2.1.3) ships session/set_mode and session/set_config_option instead. Verified against both 2.1.2 and 2.1.3 binaries.

Why the default model works: the skip condition at acp-message-execution-options.ts:35 (reported()[key] === value) bypasses the write when the selected model already equals the agent's current model.

Reproduction

  1. opencode 2.1.2 (homebrew) with a config default model A and at least one other model B (any custom provider; I used self-hosted models behind an OpenAI-compatible gateway).
  2. Open a Chat UI conversation with the OpenCode agent on model A (the config default) → works.
  3. New conversation with model B → every message is rejected within ~25 ms with OpenCode didn't accept this message.

Evidence

  • agent-session-journal.db: 5 sessions on model B, all 8 dispatches pending → rejected in ~24 ms, reason The agent didn't accept this message., rejection.kind = providerRejected; zero session/prompt reached the agent (provider-side logs show no requests).
  • Raw ACP test against opencode acp (2.1.2 and 2.1.3): initialize → session/new → session/set_model {sessionId, modelId: "B"} returns -32601 "Method not found": session/set_model. The same flow with the default model never needs the call and works.
  • strings on both binaries: session/set_mode, session/set_config_option present; session/set_model absent.
  • opencode run -m B (CLI) and the HTTP API both work — the model itself is healthy.

Verified fix path

OpenCode 2.x does implement model switching via session/set_config_option:

--> session/set_config_option {"configId": "model", "value": "<provider>/<model>"}
<== ok  (session/new's configOptions then reports currentValue = <provider>/<model>)
--> session/prompt {"prompt": "reply with exactly: ok"}
<== "ok"   (usage_update reports the selected model's context window)

Verified against 2.1.2: the switch happens and the prompt runs on the selected model.

Suggested fix

In the ACP model-write path, fall back to session/set_config_option {configId: "model", value} when session/set_model fails with -32601 (Method not found) — or, more generally, prefer the agent's advertised configOptions from session/new when it offers a model config option. The current Pi/OMP fixes (#31863, #31998) address effort-restore rejections but not this path; on main today session/set_model is still called unconditionally (acp-session-runtime.ts:224) and the opencode dialect does not override model writes.

Workarounds

  • Set the desired model as the config default in opencode.jsonc (model field) — Orca skips the write when selected == current. (Flips the failure onto the other models, so only useful when one model dominates.)
  • Use the opencode CLI/TUI for non-default models.

Related

Activity

  1. yzyDavid commented on Oct 23, 2026

    @yzyDavid
    Author

    Correction: the operative root cause for the OpenCode 2 case is the effort-admission guard fixed by #32004, not session/set_model

    Follow-up verification on my setup narrows this down, and my original analysis was wrong about the trigger:

    1. In v1.4.237, AcpStructuredOptions.write() (acp-structured-options.ts:127-134) prefers the agent-declared model config option over session/set_model. OpenCode 2 declares id: "model" (category model), so the model switch goes through session/set_config_option and succeeds — session/set_model is never called for OpenCode 2.
    2. The rejection comes from the pre-fix(chat): send pi and acp messages after a model-only change #32004 effort-admission guard in applyAcpMessageOptions: a message with no effort, on a model whose listing has no efforts/default effort, is refused whenever the agent reports one. Verified on my setup: after switching to the non-default model, OpenCode 2 reports an effort configOption (category thought_level, current "default"), so the old session.options.reported()['effort'] !== undefined condition fires → AgentSessionOptionRejectedError → "OpenCode didn't accept this message." Messages that carry an effort value (my default-model sessions) are unaffected — which is why the default model kept working.
    3. This is exactly what fix(chat): send pi and acp messages after a model-only change #32004 fixed (merged 2026-10-22, after v1.4.237 — still the latest release today): the guard now throws only when Orca itself picked the key.

    So for anyone on ≤ 1.4.237 seeing this with OpenCode 2: the fix is #32004, pending the next release.

    The session/set_model gap described in the issue body is real but latent for OpenCode 2 (it would only matter for an ACP agent that exposes a models list but no model config option — on such an agent Orca would call session/set_model and OpenCode 2 would answer -32601). Happy to split that into its own lower-priority issue, or this can be closed as covered by #32004.

  2. nwparker commented on Oct 24, 2026

    @nwparker
    Contributor

    Thanks for the detailed report, @yzyDavid. Chats failing with a model-only change (no known default effort for the selected model) were fixed in #32004 (shipped in v1.4.239): the guard now only refuses when Orca has already applied a value that differs from the agent's initial one, for both ACP and Pi RPC chats. Could you try the latest build? If it still happens, please reply or reopen with the details.

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

    os:macosIssues affecting macOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions