Skip to content

feat(list-models): mark the runtime's default model and name each model's provider - #355

Merged
xxchan merged 3 commits into
mainfrom
fix/list-models-default-provider
Oct 12, 2026
Merged

xxchan merged 3 commits into
mainfrom
fix/list-models-default-provider

Conversation

@xxchan

@xxchan xxchan commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Closes #347 (asked by Rower for rowrow users on pi).

ModelEntry.default?: true: the model a session uses when no model is set, where the runtime says so; OAR never picks one:

  • codex: the model codex's own configuration sets (config/read, user and project config for the host's cwd) when it is listed, else model/list's isDefault (app-server protocol Model.is_default, rust-v0.162.1). A configured model that is not listed marks nothing;
  • grok: the models state's currentModelId; kimi and antigravity: the model config option's currentValue on the new session the listing opens. That is the model a new session starts on;
  • pi: the default saved in pi's settings (defaultProvider / defaultModel, global plus the project at the host's cwd) when it is listed. With none saved, pi picks the first available model at session creation (findInitialModel, not exported); OAR does not guess it;
  • claude marks none: its settings (model, ANTHROPIC_MODEL) can pick a model that list_models does not reflect, so its "Default (recommended)" entry is not reliably what an unset session runs (Lookout, 2.1.296). cursor and opencode name no default.

ModelEntry.provider?: { id, displayName? }: for runtimes with several providers, so hosts do not parse id:

  • pi: the model's provider with pi's display name for it (ModelRuntime.getProvider(id).name, the name ModelRegistry.getProviderDisplayName reads), omitted when it only repeats the id; pi-durable gets the provider id;
  • opencode: providerID from opencode models --verbose (no display name there).

Tests: codex's configured model winning over isDefault (and an unlisted one marking nothing), config/read asked for the host's cwd, claude marking none, pi's provider names and saved default (and no default when the saved one is not listed), plus the existing grok, kimi, antigravity and opencode projections updated. Lint, typecheck and the list-models tests pass.

🤖 Generated with Claude Code

exe.dev user and others added 3 commits October 12, 2026 02:08
…el's provider (#347)

ModelEntry gains default (the entry the runtime itself names: claude's
default entry, codex isDefault, a new ACP session's current model on grok,
kimi and antigravity, pi's saved settings default) and provider (pi with
pi's display name, opencode's providerID). Nothing is guessed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ote pi's per-project default

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lookout's #355 check: with a model set in codex's config.toml or claude's
settings, a session with no model runs on that one, not the catalog
default. codex now reads config/read (for the host's cwd) and marks the
configured model when it is listed, else isDefault. claude's answer does
not reflect its settings, so claude marks no default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit b79c30a into main Oct 12, 2026
17 checks passed
@xxchan
xxchan deleted the fix/list-models-default-provider branch October 12, 2026 02:23
@xxchan xxchan mentioned this pull request Oct 12, 2026
xxchan added a commit that referenced this pull request Oct 12, 2026
Release OAR and CLI 0.57.0. This PR changes only the two package version
fields.

Most of this release comes from comparing OAR with the Claude Agent SDK
and the codex SDK (#342): in common host scenarios OAR should be no
worse than a runtime's own SDK.

**Added: `listModels` names the default model and each model's
provider** (#347, #355)
- `ModelEntry.default: true` marks the model a session uses when no
`model` is set, where the runtime says so: codex's configured model
(`config/read` for the host's cwd, when it is listed), else codex's
catalog `isDefault`; a new ACP session's current model on grok, kimi and
antigravity; the default saved in pi's settings (global plus the project
at the host's cwd). claude, cursor and opencode mark none, because they
cannot say which model an unset session runs. OAR never picks one.
- `ModelEntry.provider: { id, displayName? }` for runtimes with several
providers: pi (with pi's display name, omitted when it only repeats the
id) and opencode (`providerID`), so hosts never parse `id`.

**Added: host-set limits and schemas have their own failure classes**
(#339, #356)
- `limit_reached`: claude stopped at `--max-turns` or `--max-budget-usd`
(result subtypes `error_max_turns`, `error_max_budget_usd`).
- `output_schema`: the runtime could not produce output matching
`SessionOptions.outputSchema` (claude
`error_max_structured_output_retries`, grok `structuredOutputError`).
Both used to be `unknown`.
- `failureAdvice` says not to retry either until the host changes the
limit or schema; `failureText` words them.
- A claude error result's `reason` is now its subtype followed by
claude's own `errors` text (`error_max_turns: Reached maximum number of
turns (2)`).

**Added: reasoning tokens** (#345, #362)
- `TokenTotals.reasoning`: the part of `output` the runtime reports as
reasoning, on codex (`reasoningOutputTokens`), grok, pi, pi-durable and
cursor. It is already inside `output`, so do not add it again.
Unreported stays absent and a reported 0 stays 0; it accumulates,
survives resume baselines and `withChildren`, and replays the same from
JSON records. claude and the other ACP runtimes report none.

**Fixed: claude `launchArgs` that collide with OAR's own flags are
refused** (#336, #356)
- `--continue`/`-c`, `--resume`/`-r`, `--session-id`, `--fork-session`,
`--permission-mode`, `--print`/`-p`, `--input-format`, `--output-format`
and `--json-schema` (also in `--flag=value` form) are refused at open
with an `UnsupportedOptionError` naming the option to use. Before,
`--continue` made claude exit, `--fork-session` left `Session.id` on the
old id, and `--permission-mode` was silently overridden. Each argument
is compared whole, so a value equal to one of these flags is refused
too.

**Changed: `oar mcp` returns structured results** (#304, #360)
- `run`, `wait` and `list` declare an `outputSchema` and return
`structuredContent` alongside the JSON text, for clients that call tools
from code (OpenCode v2's `execute`, codex code mode).
- `wait` now returns `{ reports }` and `list` returns `{ agents, unread
}` (both were top-level arrays; `list` carries the unread reports as a
field instead of a text note).

**Fixed: `session_linked` once per edge** (#324, #361)
- A child session's lineage is emitted on the first frame that names it,
not on every frame that repeats it (OpenCode v2 repeated it on every
child frame). The graph was already deduplicated; a resumed session's
new stream reports the edge again once.

**Fixed: inventory** (#351, #357)
- claude's commands no longer carry an empty `argumentHint: ""`.
- The inventory spec says plainly that a reader starts the runtime in
`cwd` as a session would, so it can run that workspace's code: do not
inventory an untrusted directory.

**Behavior changes**
- `FailureClass` gains `limit_reached` and `output_schema`; `ModelEntry`
gains `default` and `provider`; `TokenTotals` gains `reasoning`. Hosts
with an exhaustive `switch` or `Record` need the new cases.
- `oar mcp` `wait` and `list` return objects, not arrays.
- claude error reasons are longer; claude `launchArgs` with the flags
above are refused.

Validation: every PR passed all 17 checks on its final head (#358 and
#359 change only Markdown and one comment). #355 and #356 merged with
trees equal to their CI trees; #357, #360, #361 and #362 merged after
typecheck, lint and the full unit suite passed locally on top of the PRs
merged before them. Verified against real runtimes with mock providers
and no account: codex 0.162.1 default under four configurations, pi with
two providers and saved defaults, grok, kimi and opencode listings;
claude 2.1.296 launchArgs refusals (claude not started), `--max-turns`,
`--max-budget-usd` and exhausted schema retries; grok schema errors; the
built `oar mcp` returning structured `list` and `wait`; codex 0.162.1
reasoning counts of 3 then 7 across a resume; `session_linked` once on
OpenCode v2, codex and grok recordings. After this PR passes CI and
merges, tag its exact squash commit as `v0.57.0` to trigger npm trusted
publishing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
xxchan added a commit that referenced this pull request Oct 12, 2026
Rower asked for this after 0.57.0 (#347, #355): rowrow's model menus
belong to one workspace, but `listModels` read every runtime's
configuration at the host's cwd, so `ModelEntry.default` (and on some
runtimes the list itself) could be wrong for that workspace.

**What changes**
- `ListModelsOptions.cwd`: the directory a session would run in,
resolved against the host's cwd, which stays the default. Each runtime
lists there the way a session there would start:
- claude, kimi, grok, antigravity and opencode start in it (kimi and
antigravity also open their throwaway `session/new` there);
- codex sends it as the `config/read` cwd. The app-server itself still
starts at the host's cwd, where a session's app-server starts, so a
relative `CODEX_HOME` resolves the same way;
- pi builds its settings and services for it, so the project's saved
default and its `.pi/extensions` apply.
  - cursor, pi-durable and morph list without one.
- `oar models --cwd <dir>`, and the human table marks the default model
with `(default)`.
- Contract, README and pi docs say plainly that listing in a directory
can run that workspace's code (pi loads its project extensions), like
the inventory readers, so hosts should not list in a directory they do
not trust.

**Verified against real runtimes (no tokens spent)**
- pi 1.1.0, with an isolated agent dir and a dummy xAI key: the global
default `grok-4.5` is marked without `--cwd`. With `--cwd` on a
workspace whose `.pi/settings.json` saves `grok-4.7`, that model is
marked, and the workspace's `.pi/extensions/marker.js` ran. It did not
run without `--cwd`.
- codex 0.162.0, with an isolated `CODEX_HOME` whose user config sets
`gpt-5.5`:
- a trusted workspace whose `.codex/config.toml` sets `gpt-6-luna` marks
`gpt-6-luna`;
  - the same workspace untrusted marks `gpt-5.5` (codex's own rule);
  - listing wrote nothing to `config.toml`.
- opencode 1.18.30: a provider defined in the workspace's
`opencode.json` is listed only with `--cwd` (given as a relative path).
- claude 2.1.292: the workspace's `.claude/settings.json` changes the
list; moving the file away restores it.

kimi, grok and antigravity are covered by unit tests only: their spawn
and `session/new` now use the same directory a session does.

Validation: typecheck, lint and the full unit suite (1739 tests) pass
locally.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
xxchan added a commit that referenced this pull request Oct 12, 2026
…fore restarting it (#374)

Test-only. No release needed.

## Problem

`sea-trial/vendor/claude-mcp-config.vendor.test.ts` failed twice on
macOS on 2026-10-12, with the same missing echo both times:

- main 8e4c5e4 (#364), run 38203896898, job `behavior (macos-latest,
claude-aimock)`;
- the #355 branch run at 02:08Z, same job.

```
-   "echo:restarted-stdio via=stdio token=…",
```

The other three echoes arrived.

## Cause

The stdio echo server runs with `--once`: it exits right after answering
its first call. The third step calls it again, so claude has to restart
it. If claude sends that call before it has noticed the exit, the call
goes to the exiting process. claude answers the tool call with
`"Connection closed"` (`is_error: true`) and does not restart the server
for it. On Linux claude notices the exit before the next call; on macOS
it sometimes does not.

## Change

`EchoStep` gets an optional `delayMs`: how long the model waits before
replying with that step's call. It is implemented as aimock's
`streamingProfile.ttft`, which adds a one-time delay. aimock's `latency`
would apply the delay to every streamed chunk.

The `restarted-stdio` step uses `delayMs: 1500`. The test still proves
what it is for: claude restarts the server and the restarted server gets
its credential.

Other users of `echoFixtures` are unchanged. The field is optional.

## Evidence (Linux, real claude 2.1.296, aimock, no account)

To mimic a runtime that notices the exit late, I used a local,
uncommitted patch to `tests/fixtures/echo-mcp-server.mjs`. With it, the
server exits 300 ms or 1000 ms after its answer instead of right away.

| Server exits | Without this change | With this change |
|---|---|---|
| right away (fixture as committed) | passes (6 of 6 runs) | passes
(about 4.2 s vs 3.0 s) |
| 300 ms late | fails in 11 of 12 runs: the third call gets `"Connection
closed"` and `restarted-stdio` is missing, as on macOS CI | passes in 8
of 8 runs |
| 1000 ms late | fails in 5 of 5 runs | passes in 5 of 5 runs |

Lint (`oxlint --type-aware --deny-warnings` on both files), `pnpm run
typecheck`, and the whole vendor file with `OAR_TEST=claude-aimock` (2
of 2) pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

listModels: mark the runtime's default model and name each model's provider

1 participant