Fix LLM provider resolution to use model catalog before default fallback

When no explicit provider is set on a request, resolve_provider now
consults the model catalog (e.g. gpt-5.4 → openai) before falling back
to the client's default provider. This fixes PR description generation
sending cross-provider model IDs to the wrong provider.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-03-10 12:47:24 -04:00
parent 4fe05e8a71
commit fb04333d45

View file

@ -134,9 +134,13 @@ impl Client {
/// Resolve the provider for a request.
fn resolve_provider(&self, request: &Request) -> Result<Arc<dyn ProviderAdapter>, SdkError> {
let catalog_provider =
crate::catalog::get_model_info(&request.model).map(|info| info.provider);
let provider_name = request
.provider
.as_deref()
.or(catalog_provider.as_deref())
.or(self.default_provider.as_deref())
.ok_or_else(|| SdkError::Configuration {
message: "No provider specified and no default provider set".into(),