Skip to content

feat: fetch provider models dynamically and fix isOpenSource pollution#12046

Merged
sestinj merged 1 commit intocontinuedev:mainfrom
RomneyDa:dynamic-model-fetching
Apr 8, 2026
Merged

feat: fetch provider models dynamically and fix isOpenSource pollution#12046
sestinj merged 1 commit intocontinuedev:mainfrom
RomneyDa:dynamic-model-fetching

Conversation

@RomneyDa
Copy link
Copy Markdown
Contributor

@RomneyDa RomneyDa commented Apr 5, 2026

Summary

  1. Fixes issue where isOpenSource is used to detect if a model can be used by ollama. Changes to explicit providers listing.
  2. Adds support for dynamically fetching provider models. Open router already has this, moves logic to core to unify. Adds support for ollama using their tags API. Adds support for other providers using their listModels methods (or custom for gemini/anthropic). A little refresh icon to "update models list using my API key" shows once an API key has been entered. Does some sensible filtering and model param detection for context length, max tokens, and tool use. Also these results are deduplicated with hardcoded models (hardcoded take precedence) and show proper provider icons etc.
  3. Adds explicit Gemma 4 and GPT 5.4 family support
  4. updates some tools support regex matching to match e.g. gpt 6, 7, etc.
image

Summary by cubic

Unifies dynamic model fetching across providers via a core models/fetch protocol, auto-loading ollama and openrouter, and letting users refresh other providers with their API key. Persists fetched context, max tokens, and capabilities to config.yaml, adds GPT‑5.4 (pro/mini) and Gemma 4, and removes isOpenSource-based routing.

  • New Features

    • Central models/fetch: ollama scrapes the library (icons), openrouter hits its public API on load, anthropic calls /v1/models, gemini calls v1beta/models (chat-only; excludes 2.0, Gemma, embeddings/TTS/robotics/etc.), others use listModels() with optional apiKey/apiBase; returns contextLength, maxTokens, supportsTools; errors toast and return [].
    • Add Model: Auto-loads ollama/openrouter; refresh button appears after API key to fetch provider models; merges and de‑duplicates into “Additional models”; sorts fetched models.
    • Persistence: Writes contextLength, completionOptions.maxTokens, and capabilities (tool_use, image_input) to config.yaml when adding a model.
    • Models: Adds gpt-5.4 (pro, mini) and gemma4; improves image/tool detection for Gemma 4 and future GPT 5+.
  • Bug Fixes

    • OpenAI.listModels(): Supports providers returning either a plain array or { data: [] }; error text now references config.yaml.
    • Add Model UX: Centered spinner; clears API key when switching to providers without RequiresApiKey and after adding; selects the new model by posting directly to core.
    • Routing: Replaces isOpenSource logic with explicit providerOptions and popularPackages.
    • Tool/agent heuristics: Safer regexes for GPT 5+ (gpt-[5-9]), Claude 4+, Grok 4.x+, GLM 4+; OpenAI checks use isOSeriesOrGpt5PlusModel.

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

@RomneyDa RomneyDa requested a review from a team as a code owner April 5, 2026 23:09
@RomneyDa RomneyDa requested review from sestinj and removed request for a team April 5, 2026 23:09
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Apr 5, 2026
@RomneyDa RomneyDa changed the title feat: unified models/fetch protocol for dynamic model fetching feat: fetch provider models dynamically and fix isOpenSource pollution Apr 5, 2026
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

3 issues found across 12 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="gui/src/forms/AddModelForm.tsx">

<violation number="1" location="gui/src/forms/AddModelForm.tsx:73">
P2: Late async model-fetch responses can overwrite state after provider switch, showing stale models from the previous provider.</violation>
</file>

<file name="core/llm/fetchModels.ts">

<violation number="1" location="core/llm/fetchModels.ts:100">
P2: Ollama model discovery relies on brittle scraping of `x-test-*` HTML markers, which can silently return empty/partial model lists when upstream markup changes.</violation>
</file>

<file name="gui/src/pages/AddNewModel/configs/providers.ts">

<violation number="1" location="gui/src/pages/AddNewModel/configs/providers.ts:77">
P2: Ollama catch path resets `packages` but not `popularPackages`, allowing stale popular-model state to persist across re-initializations.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai bot commented Apr 5, 2026

You're iterating quickly on this pull request. To help protect your rate limits, cubic has paused automatic reviews on new pushes for now—when you're ready for another review, comment @cubic-dev-ai review.

@RomneyDa RomneyDa force-pushed the dynamic-model-fetching branch 16 times, most recently from ebb3457 to a623767 Compare April 6, 2026 00:29
@RomneyDa RomneyDa force-pushed the dynamic-model-fetching branch from 5a414af to bcd29eb Compare April 6, 2026 05:15
@sestinj sestinj merged commit 9f9ded7 into continuedev:main Apr 8, 2026
52 of 64 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Issues and PRs Apr 8, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Apr 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants