Skip to content

Models: list a harness's models when something that decides them changes, and take them from running sessions - #1227

Merged
Tryanks merged 1 commit into
mainfrom
claude/model-catalog-lifecycle
Dec 4, 2026
Merged

Tryanks merged 1 commit into
mainfrom
claude/model-catalog-lifecycle

Conversation

@Tryanks

@Tryanks Tryanks commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Summary

A harness's models were listed once as the host started and again, for all seven harnesses, on every profile edit. Whatever a listing answered was kept, an empty list included. Two harness behaviours made that wrong:

  • OpenCode (2.4.4) answers /api/model with whatever has loaded so far until its plugins are in: 0 models, then a partial 73, then the real 31. Tcode read it the moment /api/info answered.
  • Codex (0.174.0) fetches its model catalog over the network every time codex app-server starts, whatever it is then asked. Each process Tcode starts is one fetch.
 when a harness's models are listed
   host start                                   (once, each enabled harness)
-  any profile edit, all seven harnesses         (a name or a colour too; stops the listing under way)
+  the harness's binary, home, environment or enabled state changed
+  its account signed in or out, or a secret of its was saved
+  Tcode updated its CLI
+  the user pressed Check again in the harness dialog   (new RefreshModels command)
+  never on a timer
 where the models come from
   a process started to list them
+  a running session, as AgentEvent::ProviderModels:
+    Codex     the model/list its session already makes for reasoning efforts
+    OpenCode  /api/model, read again on each model.updated
+    ACP agent its model option, whenever a config_option_update changes it
 OpenCode listing
   spawn server, wait for /api/info
-  GET /api/model                       # 0, 73 or 31 by timing
+  subscribe to /api/event
+  wait until /api/plugin lists plugins (plugin.updated announces each load)
+  GET /api/model                       # 31
 Codex at host start
-  codex app-server   → model/list
-  codex app-server   → account/rateLimits/read
+  codex app-server   → model/list, account/rateLimits/read

A change the settings do not show (sign-in, a secret, a CLI update) waits for the listing under way and lists once more, instead of stopping it; a change to what the listing is started with replaces it, since its answer is for the old configuration. A disabled harness is not listed.

A native catalog stays one per harness, as its built-in account sees it, so it takes a session's models only from that account. An ACP agent's catalog takes the models from a session and keeps the default its probe saw, because a session marks the model it is set to.

Not in this change

  • The catalog is still keyed by harness, not by profile: other accounts of a harness show the built-in account's models, as before.
  • Codex's plugin listing still starts a process of its own when the plugin settings are opened.
  • A CLI upgraded outside Tcode is listed again at the next host start, not when it happens.
  • Grok, Antigravity, Cursor and pi have no session feed: Grok's and Antigravity's session answers do not carry what their listing does, and Cursor and pi sessions never ask.
  • OpenCode's models depend on the directory; the catalog holds what the listing or the latest session of the built-in account reported, as the commands cache already does.

Evidence

  • Before (base bee52d478, fresh --data-dir, codex on PATH replaced by a shim that logs and execs the real one, 45 s after tcode-headless serve):
    codex --version
    codex app-server
    codex --version
    codex app-server
    models-opencode.json: 0 models
    
    After (this branch, same run):
    codex app-server
    codex --version
    codex --version
    models-opencode.json: 31 models
    
  • OpenCode's race, polled against the real CLI before the change, same on five runs: /api/model → 0, 73, 31, then provider.updated, model.updated, plugin.updated; /api/plugin goes from 0 to 103 at that moment. probe --list-models opencode on this branch: 31 models on seven of seven runs, from the repository and from /.
  • Codex: ~/.codex/models_cache.json's fetched_at moves on every codex app-server start, five seconds apart, with no request sent.
  • Real sessions through probe (codex and opencode, the latter from a directory other than the listing's): each emits one provider_models, equal to --list-models in ids, order, default and options. probe --list-models codex now prints the account usage read in the same process.
  • Tests added, one for each decision this adds:
    • the_models_a_session_reports_become_its_harnesss: a session of another account leaves the catalog as it was; one of the built-in account replaces and persists it.
    • the_models_a_session_reports_become_its_agents: an ACP agent's catalog takes a session's models and keeps the probe's default.
    • an_agents_models_are_reported_when_its_model_option_brings_them: a config_option_update carrying a model option yields ProviderModels once, and not again while unchanged.
  • startup_failure_reports_exit_status_and_stderr_tail gained the new read_usage argument; its assertions are untouched.
  • Checks run locally on the final commit: cargo fmt --all --check, cargo clippy --workspace --all-targets --locked -- -D warnings, cargo nextest run --workspace --locked. Not exercised: a real registry ACP agent (none installed here), Windows and Linux, and the harness dialog's Check again button in the running app.

Merge Danger

Door: Two-way.

The wire gains the RefreshModels command (noted as Unreleased above PROTOCOL_VERSION); a client from this tree pressing Check again against an older host is refused.

Blast Radius: Model pickers.

A listing that used to run on every edit now runs only for the triggers above, so a cause of model changes not among them shows up as a stale picker until the next start, a session of that harness, or Check again.

  • This change alters the wire protocol, so the next release needs a
    PROTOCOL_VERSION bump: a note was added under "Unreleased" above the
    constant in crates/protocol/src/lib.rs (the number itself changes only
    when the release is cut — CONTRIBUTING.md, principle 9).

…m changes, and taken from running sessions

OpenCode answers /api/model with whatever has loaded so far until its
plugins are in: nothing, then a partial list (2.4.4). The listing read it
the moment the server answered and kept what it got, an empty catalog
included. It now subscribes to the event stream first and reads once the
plugin list has filled, as OpenCode's own one-shot clients wait, and a
running session reads again on each model.updated.

Every codex app-server fetches Codex's model catalog over the network as
it starts (0.174.0). The process started for the models now reads the
account's usage too, and a Codex session reports the list it already
fetches for reasoning efforts, so neither starts another.

The host listed all seven harnesses on every profile edit, a display name
or a colour included, stopping the listing under way each time. It now
lists a harness again only when what its listing is started with changes
(binary, home, environment, whether any account is enabled), when its
account signs in or out, when a secret of its is saved, when Tcode
updates its CLI, or when the user asks from the harness dialog. A
disabled harness is not listed. A change that the settings do not show
waits for the listing under way and lists once more instead of stopping
it.

Sessions report models as AgentEvent::ProviderModels: Codex at start,
OpenCode on model.updated, a registry ACP agent whenever its model option
changes, which is how an agent that fills its models in after session/new
reaches the catalog. A native catalog takes them from sessions of the
harness's own account; an ACP catalog keeps the default its probe saw.
@Tryanks
Tryanks force-pushed the claude/model-catalog-lifecycle branch from 4ab950e to 0f7cd2e Compare December 4, 2026 23:16
@Tryanks
Tryanks merged commit 160970c into main Dec 4, 2026
13 checks passed
@Tryanks
Tryanks deleted the claude/model-catalog-lifecycle branch December 4, 2026 23:32
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