feat(runtime): expose session models on getStatus#300
Open
DaniAkash wants to merge 2 commits intoopenclaw:mainfrom
Open
feat(runtime): expose session models on getStatus#300DaniAkash wants to merge 2 commits intoopenclaw:mainfrom
DaniAkash wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Adds an optional `models` field to `AcpRuntimeStatus` that surfaces
the model ids the agent advertised at session-creation time. The data
already lands in `NewSessionResponse.models` and is partly persisted
on `record.acpx.{available_models, current_model_id}` — the public
runtime API just never exposed it. The CLI's status command reaches
into the private record directly today; this gives every host the
same capability.
Strictly additive at every layer:
- `AcpRuntimeStatus.models?: AcpRuntimeSessionModels` (new optional
field on an existing type)
- `AcpRuntimeSessionModels = { currentModelId?, availableModelIds }`
(new exported type)
- No persisted-state schema changes — `available_models` stays
`string[]`
- No wire-protocol changes
- No CLI changes — its existing private-record path keeps working
Display names are deliberately not surfaced here. The ACP SDK
provides `{ modelId, name }` but `name` is dropped at persistence
time today (`mode-preference.ts:137`). Surfacing names would either
require schema changes or a parallel optional field — worth a
separate follow-up if there's user demand.
Drive-by fix: `manager.ensureSession` was already capturing
`sessionResult.configOptions` via `applyConfigOptionsToRecord` but
silently dropping `sessionResult.models` — only the reconnect path
called `syncAdvertisedModelState`. Added one line to capture
models on first session creation too, mirroring the reconnect path.
Driving consumer: `acpx-ai-provider` (the Vercel AI SDK adapter)
needs this to expose `getAvailableModelIds()` so chat / picker UIs
built on AI SDK can discover what each agent supports without
reaching into private state.
Tests:
- `getStatus` populates `models` from `NewSessionResponse.models`
- `getStatus` omits `models` when the agent didn't advertise any
- `getStatus.models` survives a save/reload cycle
`pnpm check` (format + typecheck + lint + build + viewer +
test:coverage) passes locally; 605 tests, 0 failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional
modelsfield toAcpRuntimeStatusthat surfaces the model ids the agent advertised at session-creation time, plus a small drive-by fix so first-session-creation captures models the same way the reconnect path already does.Why
The data already lands in
NewSessionResponse.modelsfrom the ACP SDK and is partly persisted onrecord.acpx.{available_models, current_model_id}— but the public runtime API never exposed it. The CLI'sstatuscommand reaches into the private record directly (cli/status-command.ts:120); programmatic consumers can't.Downstream
acpx-ai-provider(the Vercel AI SDK adapter) needs this to exposegetAvailableModelIds()so chat / picker UIs built on AI SDK can discover what each agent supports without reaching into private state. Gives every host the same capability the CLI already has.This change is strictly additive at every layer — no public API breaks, no persisted-state schema changes, no wire-protocol changes.
Public surface
modelsis undefined when the agent didn't advertise any (Gemini CLI, custom adapters that omitNewSessionResponse.models).Drive-by: capture models on first session creation
manager.ensureSessionalready callsapplyConfigOptionsToRecord(record, sessionResult)to capturesessionResult.configOptions, but silently dropssessionResult.models— only the reconnect path (reconnect.ts:375) callssyncAdvertisedModelState. Added one line right afterapplyConfigOptionsToRecordto capture models on first creation too, mirroring the reconnect path. Same idempotent helper, same field on the record — just plugs the gap so models are visible before the first reconnect.What's deliberately not in this PR
{ modelId, name }onavailableModelsbutnameis dropped at persistence time today (mode-preference.ts:137). Surfacing names would either require persistence schema changes (avoided here for back-compat safety) or a parallel optional field. Worth a separate follow-up if there's user demand — for now hosts render the id as the label.setSessionModelmethod.setConfigOption('model', value)does NOT route tosetSessionModeltoday — it goes through the genericsetSessionConfigOptionpath. Adding a public model-switching method is a separate concern; this PR only exposes read state.Tests
test/runtime-manager.test.ts:getStatuspopulatesmodelsfromNewSessionResponse.modelsgetStatusomitsmodelswhen the agent didn't advertise anygetStatus.modelssurvives a save / reload cycle (proves the field is read out of the persisted record, not just in-process state)pnpm check(format + typecheck + lint + build + viewer + test:coverage) passes locally — 605 tests, 0 failures.Files touched
src/runtime/public/contract.tsAcpRuntimeSessionModels; addmodels?toAcpRuntimeStatussrc/runtime/engine/manager.tsbuildModelsFieldhelper; spread it intogetStatus; capture models on first ensureSessionsrc/runtime.tsAcpRuntimeSessionModelstest/runtime-manager.test.tsTotal: 4 files, ~177 LoC, ~72% tests.
Backwards compatibility
record.acpx?.available_modelsdirectly and is untouched.getStatus().models. The new field is?: …so destructuring continues to work.acpx-ai-provider(downstream)