Skip to content

opencode: follow the session's model in the plugin's own calls - #243

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

Have-Purple wants to merge 1 commit into
microsoft:mainfrom
Have-Purple:fix/opencode-session-model

Conversation

@Have-Purple

@Have-Purple Have-Purple commented Nov 16, 2026 •

Copy link
Copy Markdown

With neither opencode_paid_model nor paid_model set, the plugin ran opencode run with no
--model, so TE used the CLI's configured default. That default can be a free model the session
has already moved past — the resulting 429s looked like TE being broken while the session was
running fine on a paid provider.

The 2.x plugin now reports the model from session.step.started as provider/model#variant with
each hook. The session state keeps it; the loop guard's judge and the micro-skills proposer use
it when no paid_model is set. An explicit paid_model still wins, and the other hosts keep
their own defaults (Claude's haiku) — the fallback is opencode-only.

This is the second half of what was #230; the quiet hand-over is now its own PR (#230).

Review items addressed

  • Usage read stays after settle. fold.py reads session_usage after
    ctx.host.settle(transcript) again: Copilot writes usage in the SessionEnd tail, and reading
    ahead of it recorded requests: 0.
  • The session log is not a model source. It keeps a bare model id (trace/opencode.py), which
    opencode run --model cannot resolve (it wants provider/model), and the 1.x server entry
    sends none. The fold takes the model from the session state only; the test that asserted the
    bare id is replaced by one that would fail if the log were used (its log names another model).
  • Rebased onto 583fff7. The model travels through runner_for(role=..., session_model=...)
    alongside the role= argument plugin: run the loop guard's judge on Apple's on-device model (local_model=fm) #185 added, and the proposer keeps the local_runner fallback
    microskills: add te microskills forget / unforget #160 introduced.

Design note

This changes what side calls cost: they run on the session's own model and variant (#high
included), where the optimizer was described as the cheapest capable model. plugin/README.md
and docs/PLUGIN.md now say what a 2.x call runs on with no paid model configured. The quiet
hand-over — the rest of what was #230 — is that PR, so this can be discussed on its own.

Tests

  • the plugin reports the model from session.step.started with its hooks (end-to-end under
    opencode's runtime);
  • the model the plugin sends is kept in the session state;
  • side-call precedence: opencode follows the session model, an explicit paid_model wins,
    Claude stays haiku;
  • the judge and a fold both pass the model through.

Verification

opencode 2.3.0, Python 3.15, Windows. Offline suite: 1171 passed, 36 skipped, 0 failed. The
plugin's non-service tests pass, including the new model one. The two opencode service tests
fail on this machine on main as well (baseline re-run at 583fff7), so they are not evidence
about this change; CI runs them on the pinned 2.2.5.

With neither opencode_paid_model nor paid_model set, a side call ran 'opencode run' with no
--model and took the CLI's configured default. That default can be a free model the session
has already moved past; the free tier's 429 then looked like the plugin was broken while the
session ran fine on a paid provider.

The 2.x plugin now reports the model from session.step.started (provider/model#variant) with
each hook; the session state keeps it, and the loop guard's judge and the micro-skills
proposer use it where no paid_model is set. An explicit paid_model still wins, and the other
hosts keep their own defaults (Claude's haiku): the fallback is opencode-only.

The fold takes the model from the session state only: the session log keeps a bare model id,
which 'opencode run --model' cannot resolve (it wants provider/model), so it is not a source.
The usage read stays after ctx.host.settle() (Copilot writes it in the SessionEnd tail), and
the model reaches the call through runner_for(role=..., session_model=...), as microsoft#185 landed.

plugin/README.md and docs/PLUGIN.md say what a 2.x call runs on with no paid model configured.
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