Skip to content

fix(opencode): list OpenCode 2.x models before the first message - #28423

Closed
AmoabaKelvin wants to merge 4 commits into
stablyai:mainfrom
AmoabaKelvin:fix/opencode-2x-model-listing
Closed

AmoabaKelvin wants to merge 4 commits into
stablyai:mainfrom
AmoabaKelvin:fix/opencode-2x-model-listing

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​198 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​196
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​149 $\color{#cf222e}{\Huge{\mathbf{−}}}$​48 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​101

ELI5

Before a chat sends its first message, Orca fills the model picker by asking the agent which models it has. OpenCode 2.x has no command that answers that correctly, so the first OpenCode chat on a 2.x install had an empty picker. Now Orca opens a chat session with OpenCode in the background, reads the models that session offers, and deletes it.

What Changed

Before. With opencode on 2.x, Orca ran opencode models --verbose, which every 2.x release rejects. The first chat of an account had no model list until its first message.

After. On 2.x the picker lists the models before the first message, and nothing is left in the user's OpenCode history. The list is saved and reused like every agent's. On 2.x it is refreshed when a chat asks and the saved list is more than 10 minutes old; the background refreshes at app start and after a setting change skip it, because they have no chat folder to open a session in. 1.x still uses models --verbose, unchanged.

Mechanism. OpenCode's listing setting now says which releases its listing command covers (1.x) and that other releases list through a session. The model list probe gained that session path: it checks that the agent can delete a session (sessionCapabilities.delete), opens one with session/new in the folder of the chat that asked, reads its models with the same code a running chat uses, and deletes it with session/delete. An agent that cannot delete a session is not asked. The model list service now hands the asking chat's folder to the probe. Registrations mark a listing that runs in a chat's folder, and a startup or settings refresh, which has no chat, never runs it; a read without a folder skips it without counting as a failure. So a picker never waits on a listing that cannot answer it.

Why

Linked Issue

Part of #19581. The next PR, #28424, makes the OpenCode 2 launcher entry open as a chat and lists its models the same way.

Visual Proof

N/A: the picker looks the same; it now has models before the first message. Testing gives the counts.

Testing

  • New tests, each failing on the previous code: on 2.x the probe opens a session in the asking chat's folder, reads its models and deletes it, with no listing command; it opens no session on a release that cannot delete one, nor without a chat folder; a startup refresh that skips is not held, and the next read lists in its chat's folder.

  • Real OpenCode, isolated folders: on 2.0.14 and 2.0.29 a new session reported 71 and 11 models, and after session/delete OpenCode's store held no session and no file was written in the folder.

  • Real app (hidden dev builds, macOS arm64, fresh profiles, isolated OpenCode folders):

    • opencode on 2.0.29: the first chat lists 11 models before any message, and OpenCode's store holds no session afterwards.
    • OpenCode 1.19.0: the first chat lists 11 models before any message through models --verbose, and no session is created.
    • A second chat reuses the saved list without starting OpenCode again.
    • OpenCode's project list afterwards holds only the chat's folder; before this change it also held the home folder.
    • After a restart with the saved list over 10 minutes old, the startup refresh ran nothing for OpenCode 2 (Orca's trace shows no OpenCode 2 refresh until a chat asked), and a new OpenCode 2 chat opened right after listed 11 models.
  • pnpm lint, pnpm tc, the three audits, check:code-quality:changed, check:react-doctor:changed and check:zustand-selector-fanout pass on the head. 56 dependent test files pass (563 tests)..

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Not tested: Windows, Linux and a signed-in OpenCode account.
  • If the delete never arrives (OpenCode exits, the listing times out, or Orca quits in the second between), one empty conversation is left in OpenCode's history, in the chat's folder. The model list is still saved.
  • Found while testing, not caused by this PR: OpenCode's free models now refuse requests from other apps ("OpenCode's free tier can only be used from within OpenCode"), on 1.19.0 and 2.0.29 alike. Orca's OpenCode chats show it as a sign-in prompt. I could not test a signed-in account.
  • Per-project model lists, unchanged from main: Orca keeps one model list per account, while OpenCode can add models in a project's own config. A list read in project A is shown in project B until a chat in B reports its own. Main already does this through running chats' lists. bb keeps OpenCode's list per project folder; doing that here changes the shared model list for every agent and every screen that reads it, so it is left for its own PR.
  • Backwards compatibility: no setting, stored data or wire change.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@AmoabaKelvin
AmoabaKelvin force-pushed the fix/opencode-2x-model-listing branch 2 times, most recently from 14a8f4b to 00a1f6b Compare October 15, 2026 14:04
@AmoabaKelvin AmoabaKelvin changed the title fix(opencode): stop asking OpenCode 2.x for a model list it does not have fix(opencode): list OpenCode 2.x models before the first message Oct 15, 2026
@AmoabaKelvin
AmoabaKelvin force-pushed the fix/opencode-2x-model-listing branch 2 times, most recently from 0dddffa to 5d82644 Compare October 15, 2026 21:15
…have

Every 2.x release rejects `opencode models --verbose`, and its own listings are empty before 2.0.27 and can omit providers that report after startup. The early listing now applies to the 1.x line only; on 2.x the chat's own list fills the picker.
…nd deletes

2.x has no listing command that matches its chats, but a new session reports exactly what a chat offers. The catalog probe now opens one, reads its models and deletes it with session/delete. A release that cannot delete a session is not asked, so no empty conversation is left; 1.x keeps its models --verbose listing.
OpenCode 2 records a project for every folder a session opens in, so the throwaway session in the home folder left a home-folder project in OpenCode's list. The session now opens in the folder of the chat that asked, as bb does; a startup or settings refresh has no chat, so it skips the listing without counting as a failure.
A picker opened during a startup refresh joined a listing that had no chat folder to open its session in, so it was answered with no models. Registrations now mark a listing that runs in the asking chat's folder, and the prewarm skips it, so the picker's own read lists in its folder. bb likewise keeps its folder-less prewarm apart from folder reads.
@AmoabaKelvin
AmoabaKelvin force-pushed the fix/opencode-2x-model-listing branch from 5d82644 to 706c315 Compare October 15, 2026 23:08
@AmoabaKelvin

Copy link
Copy Markdown
Collaborator Author

Folded into #28424, which now carries the model list work as well as the OpenCode 2 chat, so there is one PR to review.

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