Skip to content

fix(cli): expand AUTODETECT model entries before sending API requests - #12755

Closed
rodboev wants to merge 2 commits into
continuedev:mainfrom
rodboev:pr/cli-autodetect-expansion
Closed

rodboev wants to merge 2 commits into
continuedev:mainfrom
rodboev:pr/cli-autodetect-expansion

Conversation

@rodboev

@rodboev rodboev commented Jun 18, 2026 •

Copy link
Copy Markdown

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() to ModelService.ts that iterates model configs, detects entries with model: "AUTODETECT", creates a temporary LLM API client, calls list() 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.ts and core/config/yaml/models.ts is 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: AUTODETECT in ~/.continue/config.yaml, run continue 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() in ModelService.ts to resolve AUTODETECT via list() and replace with concrete model configs.
    • Hooked into doInitialize() before model filtering/selection; skips work if no AUTODETECT entries.
    • Logs a warning and skips on failures or empty results; filters out AUTODETECT from provider responses.
    • Added unit tests for success, passthrough, failures, empty results, and mixed configs.

Written for commit 3051179. Summary will update on new commits.

Review in cubic

@rodboev
rodboev requested a review from a team as a code owner June 18, 2026 01:09
@rodboev
rodboev requested review from sestinj and removed request for a team June 18, 2026 01:09
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 18, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@rodboev rodboev closed this Oct 29, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Continue/CLI does not handle local ollama AUTODETECT directive correctly

1 participant