Summary
Expose dreb's existing model fallback resolution with live availability probing over the RPC interface, so RPC clients can resolve "the first actually-available model from an ordered list" — the same way subagent fallback lists already work internally.
Motivation
dreb already has battle-tested logic for this in src/core/tools/subagent.ts:
resolveModelForSubagentSpawn() — walks an ordered fallback list, returns the first model that resolves and passes a live probe.
probeModelAvailability() — sends a minimal "hi" → "OK" completion via completeSimple and treats runtime-unavailable errors (isRuntimeUnavailableError, e.g. LanguageModelNotAvailable / ProxyModelNotFound) as a skip-to-next signal, with a timeout.
This is currently only reachable from inside the agent process for subagent spawns. RPC clients have no way to get it.
The existing RPC resolve_model command (src/modes/rpc/rpc-mode.ts) only resolves a single pattern against the configured registry — it does not perform a live availability check. On proxies with no /models list endpoint, the registry keeps listing a model after it has actually been decommissioned, so resolve_model returns a model that then fails at spawn time.
Concrete use case
An RPC consumer app needs a model dropdown with an automatic fallback chain (e.g. opus → sonnet → gpt-5.5) because access to a preferred model may be removed at any time. The app needs to detect live availability and settle on the first working model before spawning the agent. Today it has no choice but to hand-roll a proxy-specific HTTP probe (duplicating the endpoint/quirk/error-code handling dreb already owns). Once this primitive exists, that hand-rolled probe can be replaced with a single RPC call.
Proposed Behavior
Add an RPC command that resolves an ordered fallback list against live availability and returns the first model that passes the probe. Two shape options (pick whichever fits the RPC conventions best):
- Extend
resolve_model to accept an ordered list of patterns plus an opt-in probe: true flag, or
- Add a dedicated command (e.g.
resolve_model_fallback) taking patterns: string[] and returning { model, skippedModels?, warning? }.
Wire it in src/modes/rpc/rpc-mode.ts to reuse resolveModelForSubagentSpawn / probeModelAvailability against the session's modelRegistry (so API keys never leave the process). Add a corresponding RpcClient method in src/modes/rpc/rpc-client.ts mirroring the existing resolveModel().
Acceptance Criteria
Technical Notes
- Core logic:
src/core/tools/subagent.ts — resolveModelForSubagentSpawn, probeModelAvailability, SkippedFallbackModel, isRuntimeUnavailableError.
- RPC wiring:
src/modes/rpc/rpc-mode.ts (resolve_model / get_available_models cases), src/modes/rpc/rpc-types.ts, src/modes/rpc/rpc-client.ts (resolveModel).
- Respect abort signals and a sane probe timeout (the subagent path already does).
Summary
Expose dreb's existing model fallback resolution with live availability probing over the RPC interface, so RPC clients can resolve "the first actually-available model from an ordered list" — the same way subagent fallback lists already work internally.
Motivation
dreb already has battle-tested logic for this in
src/core/tools/subagent.ts:resolveModelForSubagentSpawn()— walks an ordered fallback list, returns the first model that resolves and passes a live probe.probeModelAvailability()— sends a minimal"hi"→"OK"completion viacompleteSimpleand treats runtime-unavailable errors (isRuntimeUnavailableError, e.g.LanguageModelNotAvailable/ProxyModelNotFound) as a skip-to-next signal, with a timeout.This is currently only reachable from inside the agent process for subagent spawns. RPC clients have no way to get it.
The existing RPC
resolve_modelcommand (src/modes/rpc/rpc-mode.ts) only resolves a single pattern against the configured registry — it does not perform a live availability check. On proxies with no/modelslist endpoint, the registry keeps listing a model after it has actually been decommissioned, soresolve_modelreturns a model that then fails at spawn time.Concrete use case
An RPC consumer app needs a model dropdown with an automatic fallback chain (e.g.
opus → sonnet → gpt-5.5) because access to a preferred model may be removed at any time. The app needs to detect live availability and settle on the first working model before spawning the agent. Today it has no choice but to hand-roll a proxy-specific HTTP probe (duplicating the endpoint/quirk/error-code handling dreb already owns). Once this primitive exists, that hand-rolled probe can be replaced with a single RPC call.Proposed Behavior
Add an RPC command that resolves an ordered fallback list against live availability and returns the first model that passes the probe. Two shape options (pick whichever fits the RPC conventions best):
resolve_modelto accept an ordered list of patterns plus an opt-inprobe: trueflag, orresolve_model_fallback) takingpatterns: string[]and returning{ model, skippedModels?, warning? }.Wire it in
src/modes/rpc/rpc-mode.tsto reuseresolveModelForSubagentSpawn/probeModelAvailabilityagainst the session'smodelRegistry(so API keys never leave the process). Add a correspondingRpcClientmethod insrc/modes/rpc/rpc-client.tsmirroring the existingresolveModel().Acceptance Criteria
probeModelAvailabilitypath (no duplicated probe logic).SkippedFallbackModel) so clients can surface "X unavailable, using Y".resolve_modelis unchanged (backward compatible).RpcClientexposes a typed method for the new capability.Technical Notes
src/core/tools/subagent.ts—resolveModelForSubagentSpawn,probeModelAvailability,SkippedFallbackModel,isRuntimeUnavailableError.src/modes/rpc/rpc-mode.ts(resolve_model/get_available_modelscases),src/modes/rpc/rpc-types.ts,src/modes/rpc/rpc-client.ts(resolveModel).