diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py index 62695af83a..3017e7703d 100644 --- a/agent/auxiliary_client.py +++ b/agent/auxiliary_client.py @@ -3132,8 +3132,14 @@ def _resolve_task_provider_model( if task: # Config.yaml is the primary source for per-task overrides. - if cfg_base_url: + if cfg_base_url and cfg_api_key: + # Both base_url and api_key explicitly set → custom endpoint. return "custom", resolved_model, cfg_base_url, cfg_api_key, resolved_api_mode + if cfg_base_url and cfg_provider and cfg_provider != "auto": + # base_url set without api_key but with a known provider — use + # the provider so it can resolve credentials from env vars + # (e.g. OPENROUTER_API_KEY) instead of locking into "custom". + return cfg_provider, resolved_model, cfg_base_url, None, resolved_api_mode if cfg_provider and cfg_provider != "auto": return cfg_provider, resolved_model, None, None, resolved_api_mode