Skip to content

fix: use dynamic model listing for all providers#7065

Closed
rabi wants to merge 1 commit intoblock:mainfrom
rabi:dynamic_model
Closed

fix: use dynamic model listing for all providers#7065
rabi wants to merge 1 commit intoblock:mainfrom
rabi:dynamic_model

Conversation

@rabi
Copy link
Contributor

@rabi rabi commented Feb 7, 2026

Summary

Remove the early return in get_provider_models that returned static model names for declarative/custom providers. Now all providers go through fetch_recommended_models() first, with static known_models from metadata as fallback when fetching fails or returns empty. Respect allows_unlisted_models for free-text model input. Aligns both cli and ui behavior.

Type of Change

  • Feature
  • Bug fix
  • Refactor / Code quality
  • Performance improvement
  • Documentation
  • Tests
  • Security fix
  • Build / Release
  • Other (specify below)

AI Assistance

  • This PR was created or reviewed with AI assistance

Testing

Unit tests and tested locally.

Related Issues

Relates to #7022

Remove the early return in get_provider_models that returned static model
names for declarative/custom providers. Now all providers go through
fetch_recommended_models() first, with static known_models from metadata
as fallback when fetching fails or returns empty. Respect
allows_unlisted_models for free-text model input. Align CLI configure
dialog with the same fallback behavior.

Signed-off-by: rabi <ramishra@redhat.com>
Copy link
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

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

so this seems like an improvement, but it looks like we're returning the static list when the dynamic list throws an error. should we not propogate that error and only return the static list if the remote return an empty list, i.e. is not implemented? we now use the fetch models in the desktop as a way to establish whether we actually have a working provider. before we had something similar as what I think is going on here and if you had your ollama misconfigured, it would show you 5 random models rather than telling you the provider didn't work.

Path(name): Path<String>,
) -> Result<Json<Vec<String>>, ErrorResponse> {
let loaded_provider = goose::config::declarative_providers::load_provider(name.as_str()).ok();
// TODO(Douwe): support a get models url for custom providers
Copy link
Collaborator

Choose a reason for hiding this comment

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

W00t!

@rabi
Copy link
Contributor Author

rabi commented Feb 8, 2026

but it looks like we're returning the static list when the dynamic list throws an error. should we not propogate that error and only return the static list if the remote return an empty list, i.e. is not implemented? we now use the fetch models in the desktop as a way to establish whether we actually have a working provider. before we had something similar as what I think is going on here and if you had your ollama misconfigured, it would show you 5 random models rather than telling you the provider didn't work.

Thanks @DOsinga for looking at it. I had tried to keep it as UX friendly as possible.

  1. I think we're not using random models for fallback but a list of known models in the metadata like ‎crates/goose/src/providers/declarative/groq.json which we can trust

  2. Also, I wanted to keep the existing behavior of listing known models

  3. There may be some declarative providers that may not have have api to list models and fetch_supported_models would return an error in that case, so the fallback to known models seems necessary

  4. I agree the desktop shouldn't rely on model listing as a provider health check — that was already broken for declarative providers (old code returned static models without any API call). I'll file a follow-up to add proper provider verification to the desktop, similar to the CLI's test_provider_configuration() which makes a real API call. That would cleanly separate "list models for the user" from "verify the provider", if that works?

@codefromthecrypt
Copy link
Collaborator

I agree with @DOsinga that we should stop papering over model list failures. I implemented the alternative here #7074

@rabi
Copy link
Contributor Author

rabi commented Feb 8, 2026

I agree with @DOsinga that we should stop papering over model list failures. I implemented the alternative here #7074

Declarative providers may not have a model listing API, we make the API call, but the actual inference endpoint might not implement /models. Built-in providers like Vertex AI handle this by overriding fetch_supported_models with a known model list, but declarative providers can't do that as they're defined by JSON and use the underlying provider's fetch_supported_models which makes a real API call, Having said that, if we want to go that route we can, though the curated model list we maintain would be redundant for the purpose

@codefromthecrypt
Copy link
Collaborator

@rabi My read looking at the logic is that we are suggesting models out of a list of potentially hundreds due to fewer working with tools or tested with goose. this leaves:

  • providers who implement list model (honestly should be all except few exception) and which are suggested
  • providers who are hacking around lack of a model list and the suggested == only known lists. (esp with ACP this should approach zero after we delete CLI providers)

That's the idea in simplifying this problem. The more 3 level if statements we have, the harder it is to maintain and also the more unlike this codebase becomes vs model abstractions. I think as long as we make docs more coherent, we can de-tempt folks from being "too smart" with errors and still have a recommended list.

My 2p

@codefromthecrypt
Copy link
Collaborator

obviated by #7074

@rabi
Copy link
Contributor Author

rabi commented Feb 9, 2026

obviated by #7074

As expected #7074 https://github.com/block/goose/blob/main/crates/goose/src/providers/claude_code.rs#L497, broke the current workflow with cli configure, the only way you can workaround it is by forcing the model with env vars..

RUST_LOG=debug ./target/debug/goose configure


┌   goose-configure 
│
◇  What would you like to configure?
│  Configure Providers 
│
◇  Which model provider should we use?
│  Claude Code CLI 
│
●  CLAUDE_CODE_COMMAND is already configured
│  
◇  Would you like to update this value?
│  No 
│
◇  Model fetch complete
│
◆  Select a model:
│  ● sonnet 
│  ○ opus 

◇  Select a model:
│  opus 
│
◐  Checking your configuration...                                                                                                                                                                                   └  Configuration saved successfully to /tmp/.config/goose/config.yaml

RUST_LOG=debug ./target/debug/goose session
starting session | provider: claude-code model: opus
    session id: 20260209_4
    working directory: /tmp/work/LLM/goose

goose is running! Enter your instructions, or try asking what goose can do.

Context: ○○○○○○○○○○ 0% (0/128000 tokens)
( O)> can you write a poem of 20 lines with start and end markers?
API Error: 404 {"error":{"code":404,"message":"Publisher Model `projects/itpc-gcp-core-pe-eng-
claude/locations/us-east5/publishers/anthropic/models/claude-opus-4-1@20250805` was not found or your project does not have access to it. Please ensure you are using a valid model version. For more information, see: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions","status":"NOT_FOUND"}}

⏱️  Elapsed time: 6.43s
Context: ○○○○○○○○○○ 0% (0/128000 tokens)
( O)> Press Ctrl+C again to exit, or type new instructions to continue
Closing session. Session ID: 20260209_4

GOOSE_PROVIDER=claude-code GOOSE_MODEL=claude-opus-4.6 ./target/debug/goose session
starting session | provider: claude-code model: claude-opus-4.6
    session id: 20260209_6
    working directory: /tmp/work/LLM/goose

goose is running! Enter your instructions, or try asking what goose can do.

Context: ○○○○○○○○○○ 0% (0/200000 tokens)
( O)> can you write a poem of 20 lines with start and end markers?
I'll write a 20-line poem for you with start and end markers.

---START---
In circuits deep where silicon dreams flow,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants