Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion crates/goose/src/providers/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,15 @@ async fn init_registry() -> RwLock<ProviderRegistry> {
true,
Some(registrations::openai_inventory()),
);
registry.register::<OpenRouterProvider>(true);
registry.register_with_inventory::<OpenRouterProvider>(
true,
Some(registrations::refresh_only().with_configured(|| {
let config = crate::config::Config::global();
config
.get_secret::<serde_json::Value>("OPENROUTER_API_KEY")
Comment thread
Abhijay007 marked this conversation as resolved.
.is_ok()
})),
);
registry.register_with_inventory::<PiAcpProvider>(
false,
Some(registrations::pi_acp_inventory()),
Expand Down
21 changes: 17 additions & 4 deletions crates/goose/src/providers/openrouter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,11 @@ impl Provider for OpenRouterProvider {
&self.name
}

/// Fetch supported models from OpenRouter API (only models with tool support)
async fn fetch_supported_models(&self) -> Result<Vec<String>, ProviderError> {
fn skip_canonical_filtering(&self) -> bool {
true
}
Comment thread
Abhijay007 marked this conversation as resolved.

async fn fetch_recommended_models(&self, toolshim: bool) -> Result<Vec<String>, ProviderError> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep OpenRouter fetch_supported_models populated

Because this moves the OpenRouter API catalogue fetch from fetch_supported_models to only fetch_recommended_models, any caller that asks for supported models now falls back to the trait default Ok(vec![]); for example the ACP ProviderSupportedModelsListRequest handler in crates/goose/src/acp/server/providers.rs:481-484 still calls fetch_supported_models() directly. In that path, configured OpenRouter users will see an empty supported-models response even though the API has models, so keep a fetch_supported_models override and have the recommended-model filtering layer build on top of it.

Useful? React with 👍 / 👎.

let response = self
.api_client
.request("api/v1/models")
Expand Down Expand Up @@ -273,10 +276,20 @@ impl Provider for OpenRouterProvider {
.iter()
.filter_map(|model| {
let id = model.get("id").and_then(|v| v.as_str())?;
Some(id.to_string())
if toolshim {
return Some(id.to_string());
}
let supports_tools = model
.get("supported_parameters")
.and_then(|v| v.as_array())
.is_some_and(|params| params.iter().any(|p| p.as_str() == Some("tools")));
if supports_tools {
Some(id.to_string())
} else {
None
}
})
.collect();

models.sort();
Comment thread
Abhijay007 marked this conversation as resolved.
Ok(models)
}
Expand Down