The cached product catalog lists models the product knows about, not the ones provisioned for the signed-in account. Probe each candidate once and keep only the ones that answer, while preserving the catalog whenever the probe is inconclusive (offline, expired token, 5xx).
2.1 KiB
CodeBuddy model availability probe
The CodeBuddy product config cached in ~/.codebuddy/local_storage/ is a
product catalog. It lists models the product knows about, not the ones the
signed-in account can call. Choosing a model that is not provisioned for the
account fails at request time with 11102 service info not found.
deeptutor/services/llm/provider_core/codebuddy_model_probe.py filters that
list before it reaches the Settings model dropdown:
fetch_codebuddy_models()reads the cached product config as before.- Each candidate gets one minimal streaming completion (
max_tokens: 1) under the shared CodeBuddy OAuth session. Requests are bounded by concurrency 6, a 6 s per-request timeout and a 20 s total budget. - Only models that answer are returned.
11102means the account cannot call the model, so it is hidden.11150means a reasoning model rejected the bare request, so it is retried once withreasoning_effort: "medium"instead of being hidden. - Results are memoised per account for 6 hours; a repeat sync makes no network calls.
Failure policy
An outage, an expired token, a rate limit or a 5xx is not evidence that a
model is missing. Those probes are inconclusive and the caller keeps the
catalog unchanged, so an offline launch never empties the model list. If every
probe is inconclusive, available_codebuddy_models() returns None and
fetch_codebuddy_models() falls back to the unfiltered cache.
Set DEEPTUTOR_CODEBUDDY_PROBE_MODELS=0 to disable probing (the previous
behaviour). No Agent SDK and no codebuddy CLI subprocess are needed; the
probe uses httpx, already a project dependency.
Evidence
Measured on a macOS desktop build against an education-edition account with
43 cached candidates: 27 answered 200, 15 returned 11102, 1 returned
11134 (temporarily unavailable). The Settings endpoint returned exactly the
27 usable models, with no 11102 entries. Cold start added ~5 s on the first
launch and 0 s on cached launches.
Run the unit tests with:
pytest tests/services/llm/test_codebuddy_model_probe.py -q