Skip to content

agent-session: pi rejects every prompt when the composer model differs from pi's startup model (deterministic, prompt never written) #32072

Closed

Description

@jasonvagner

Environment

  • Orca 1.4.237 (Linux AppImage, Ubuntu/Wayland)
  • pi (@earendil-works/pi-coding-agent) 1.4.0
  • Agent: pi (JSONL-RPC structured chat), Linux

Summary

In a new pi chat, every send is rejected with the generic "Pi didn't accept this message." whenever the model selected in the composer differs from the model pi reported at startup (get_state). The rejection is deterministic (retries fail identically) and happens before anything is written to pi — pi never creates a session transcript, and there is no prompt on the RPC pipe.

This is distinct from #31423: that one is the ACP providerHandle: "pending" race, where a retry usually succeeds.

Repro

  1. Make pi's startup model differ from the model selected in the Orca composer, e.g. pi reports opencode-go/deepseek-v4.1-flash while the composer pins opencode-go/beam-free (this happens after changing pi's default model/provider in settings.json, or when Orca restores a last-used model).
  2. Open a new pi chat and send any message.
  3. Observe: immediate rejection, no session file created under ~/.pi/agent/sessions/<cwd-slug>/, nothing sent to the agent.

Sends that carry no model (composer left at default) or that match pi's startup model are accepted, so the failure depends only on the mismatch, not on provider identity.

Evidence

Session journal (agent-session-journal.db) for the failing chat:

time record detail
10:22:19.020 epoch session_created handle pending
10:22:22.021 submission options: {"model": "opencode-go/beam-free"}
10:22:22.607 agentSession.startup outcome=ready, spawn_to_outcome_ms=302, startup model opencode-go/deepseek-v4.1-flash
10:22:22.609 dispatch state=pending
10:22:22.616 dispatch state=rejected, rejection.kind=providerRejected (7 ms later)

Driving the same pi binary by hand with the same cwd / PI_CODING_AGENT_DIR / --mode rpc, both calls succeed, so the wire protocol is fine on pi's side:

>> {"type":"set_model","provider":"opencode-go","modelId":"beam-free"}
<< {"success":true,"data":{"id":"beam-free",...}}
>> {"type":"prompt","message":"testing","images":[],"streamingBehavior":"followUp"}
<< {"success":true,"data":{"disposition":"started"}}

Cause (pi adapter, LQ / SQ)

Before writing a prompt, the adapter applies pending options:

let a = t.executionOptions?.model ?? e.initialOptions.model;
if (!t.executionOptions) return e.submit(...);

for (let n of [`model`, `effort`]) {
  let r = t.executionOptions?.[n]
        ?? (n === `model` || a === e.initialOptions.model ? e.initialOptions[n] : undefined);

  if (r === undefined && e.optionProof.writes.has(n))
    throw new q(Error(`The default ${n} for this model is unknown`));  // thrown here
  ...
}

and SQ records a pending effort write whenever a model write happens, without clearing it afterwards:

if (a?.writes.set(n, c), a?.current.delete(n),
    n === `model` && (a?.writes.set(`effort`, c), a?.current.delete(`effort`)))
  ...
await w.r(e.request(o, s, {timeoutMs: i.timeoutMs}), i.signal);
return t.set(n, r), a?.current.set(n, r), Object.fromEntries(t);   // writes never cleared

So with a model mismatch: (1) the model write runs and sets writes = {model, effort}; (2) the send carries no effort, and the initialOptions.effort fallback only applies when a === initialOptions.model, which is false; (3) writes.has('effort') is true → throw → dispatch recorded as providerRejected → UI renders the generic rejection string.

writes is never reset for the life of the session, so every subsequent send with the same pinned model fails the same way.

Suggested fix

Resolve the effort for the newly selected model instead of throwing — e.g. use the per-model defaultEffort / thinkingLevelMap already returned by get_available_models (the adapter fetches it in xQ), or clear optionProof.writes after a successful write and treat "unknown default effort" as "leave the agent's own default in place". Sending an explicit effort with the message whenever model is sent would also avoid the path.

Workaround

Align pi's startup model with the composer's selection so no option write is attempted, e.g. in ~/.pi/agent/settings.json:

{ "defaultProvider": "opencode-go", "defaultModel": "beam-free", "defaultThinkingLevel": "high" }

Related: #31423 (ACP pending-handle race, retry usually recovers), and opencode models --verbose no longer existing in opencode 2.x, which breaks the opencode (v1) agent's model discovery — the separate opencode2 agent id is unaffected.

Activity

  1. jasonvagner commented on Oct 22, 2026

    @jasonvagner
    Author

    Found the same root cause hitting a second agent — opencode2 (ACP) — so posting the evidence here rather than in a separate issue, since the missing piece is identical: defaultEffort is never populated for a newly selected model.

    Symptom

    Same user-visible string, different adapter. In an opencode2 chat, sending on any model that advertises a thinking level (opencode-go/beam-free, opencode/deepseek-v4.1-flash-free, deepseek/deepseek-flash, …) is rejected instantly. Models without thought levels (opencode/big-pickle) work.

    Evidence

    Journal: rejection 4–15 ms after submit, rejection.kind = providerRejected, handle pending.

    Captured the ACP wire by putting a tee shim in front of the opencode2 binary. Orca's writes all succeed and the prompt is simply never sent:

    >> initialize
    >> session/new                → current model opencode-go/beam-free
    >> session/set_config_option  {"configId":"model","value":"opencode/deepseek-v4.1-flash-free"}   OK
    >> session/set_config_option  {"configId":"model","value":"deepseek/deepseek-flash"}             OK
       (no session/prompt, ever)
    

    For the record, session/set_model is gone in opencode 2.x (-32601 Method not found); Orca correctly uses session/set_config_option here, which opencode accepts for model, effort and mode.

    Cause

    yX() in the ACP runtime:

    let a = e.options.messageDefault();
    let o = t?.model ?? a.model;
    let s = o === a.model ? a.effort
                          : e.options.read().models.find(m => m.id === o)?.defaultEffort;
    for (let key of [`model`, `effort`]) {
      let c = t?.[key] ?? (key === `model` ? a.model : s);
      if (c === undefined) {
        if (e.options.picked.has(key) || e.options.reported()[key] !== undefined)
          throw new q(Error(`The default ${key} for this model is unknown`));  // ← here
      }
      ...
    }

    opencode2's session/new reports the effort as currentValue: "default", so reported().effort !== undefined and the lookup falls to the catalog. In agent-model-catalog.json on this machine every opencode2 entry has defaultEffort: None, including entries whose efforts array does carry the values ([low, medium, high, xhigh, max, default]). So c === undefined → throw → the dispatch is recorded as providerRejected and nothing is written to the agent.

    Only models without a thinking level escape it: their session/new has no effort config option, so reported().effort is undefined and the loop skips the effort key — which is exactly why opencode/big-pickle works today.

    (For contrast, the stale opencode-v1 entry in the same file, produced by the old models --verbose parsing path, does have defaultEffort: "low" — so the field is populated by j0()'s variant mapping, just never by the probe/ACP-configOptions paths, and never for pi either — see the repro in the original report.)

    Suggested fix

    Either:

    • set defaultEffort from the session's configOptions (currentValue when it is a concrete level) or from the model's efforts[0] when the reported value is the literal "default", or
    • treat "default" as "let the agent decide" and skip the effort write instead of throwing.

    Workaround used here

    Declaring the capability off in opencode.jsonc removes the effort option from session/new, which makes the session look like big-pickle:

    "providers": {
      "opencode-go": { "models": { "beam-free": { "capabilities": { "reasoning": { "supported": false } } } } },
      "opencode":    { "models": { "beam-free": { "capabilities": { "reasoning": { "supported": false } } } } }
    }

    Verified: configOptions becomes [model, mode] and the chat works. Cost: no thinking-level control for those models in opencode, including the terminal.

  2. nwparker commented on Oct 24, 2026

    @nwparker
    Contributor

    Thanks for the detailed report, @jasonvagner. 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.

  3. jasonvagner commented on Oct 26, 2026

    @jasonvagner
    Author

    It's working for me now. Thanks for the quick turn-around. Much appreciated.

  4. nwparker commented on Oct 27, 2026

    @nwparker
    Contributor

    This is fixed on main by #32004 (752f531): the ACP/Pi send guard now only refuses when Orca has already applied an effort that differs from the session's initial one, so a model-only change no longer rejects the prompt (and thanks for confirming it works for you). It shipped in v1.4.239. Closing — please reopen if you still see it on a build that includes that change.

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