fix(cli): expand AUTODETECT model entries before sending API requests
Summary
Fixes #12633
The CLI does not expand AUTODETECT model entries into actual model names before sending API requests. When a user configures Ollama (or any provider) with model: AUTODETECT in their config, the VS Code and JetBrains extensions call listModels() to discover available models and replace the placeholder. The CLI skips this step entirely, sending literal "AUTODETECT" as the model name in chat completion requests, which causes 400 errors from the provider.
Root cause
The CLI has its own config loading pipeline (configLoader.ts -> ModelService.ts) that is separate from the extension path (core/config/load.ts, core/config/yaml/models.ts). The extension path checks for model === "AUTODETECT" and calls listModels() to expand it into real model entries. The CLI's ModelService.doInitialize() passes the raw ModelConfig[] from the unrolled assistant config directly to createLlmApi() without checking for or expanding AUTODETECT entries.
Changes
- Add
expandAutodetectModels()toModelService.tsthat iterates model configs, detects entries withmodel: "AUTODETECT", creates a temporary LLM API client, callslist()to discover available models, and replaces each AUTODETECT entry with concrete model configs - Call expansion during
doInitialize()before model filtering and selection - Match the extension behavior: log a warning and skip gracefully if model listing fails
- Add unit tests covering successful expansion, failed listing, empty results, and non-AUTODETECT passthrough
What this doesn't change
- The extension path AUTODETECT logic in
core/config/load.tsandcore/config/yaml/models.tsis untouched - No changes to the config YAML schema or config loading pipeline
- No changes to the openai-adapters package
- Tab autocomplete model handling is unaffected
Checklist
- Code follows project conventions
- Tests pass locally
- Prettier formatting verified
- No unrelated changes included
Tests
extensions/cli/src/services/ModelService.test.ts- new test cases for AUTODETECT expansion- Manual test: configure Ollama with
model: AUTODETECTin~/.continue/config.yaml, runcontinue chat, verify models are listed and requests succeed
Summary by cubic
The CLI now expands AUTODETECT model entries into real model names before calling providers, matching extension behavior and preventing 400 errors when using sources like Ollama.
- Bug Fixes
- Added
expandAutodetectModels()inModelService.tsto resolveAUTODETECTvialist()and replace with concrete model configs. - Hooked into
doInitialize()before model filtering/selection; skips work if noAUTODETECTentries. - Logs a warning and skips on failures or empty results; filters out
AUTODETECTfrom provider responses. - Added unit tests for success, passthrough, failures, empty results, and mixed configs.
- Added