Skip to content
Open
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
9 changes: 7 additions & 2 deletions agent/auxiliary_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3983,8 +3983,13 @@ def _resolve_task_provider_model(
if task:
# Config.yaml is the primary source for per-task overrides.
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
# Both base_url and api_key explicitly set. Preserve an explicit
# provider so downstream provider-specific logic still applies
# (e.g. transport quirks / parameter guards) on custom endpoints.
effective_provider = (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please preserve this identity only for a recognized provider-backed route. Current main's _preserve_provider_with_base_url() keeps unknown/custom values on the generic custom path; otherwise an unknown configured name reaches resolve_provider_client()'s no-client branch instead of using the explicit endpoint.

cfg_provider if cfg_provider and cfg_provider != "auto" else "custom"
)
return effective_provider, 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
Expand Down
45 changes: 45 additions & 0 deletions tests/agent/test_vision_resolved_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,48 @@ def test_vision_base_url_override_keeps_explicit_provider():
assert model == "glm-4v"
assert mock_resolve.call_args.args[0] == "zai"
assert mock_resolve.call_args.kwargs["explicit_base_url"] == "https://open.bigmodel.cn/api/paas/v4"


def test_resolve_task_provider_model_preserves_provider_with_custom_endpoint():
"""auxiliary.<task>.provider must survive when base_url+api_key are both configured."""
from agent.auxiliary_client import _resolve_task_provider_model

with patch(
"agent.auxiliary_client._get_auxiliary_task_config",
return_value={
"provider": "zai",
"model": "glm-4v-flash",
"base_url": "https://open.bigmodel.cn/api/paas/v4/",
"api_key": "sk-test",
"api_mode": "chat_completions",
},
):
provider, model, base_url, api_key, api_mode = _resolve_task_provider_model(task="vision")

assert provider == "zai"
assert model == "glm-4v-flash"
assert base_url == "https://open.bigmodel.cn/api/paas/v4/"
assert api_key == "sk-test"
assert api_mode == "chat_completions"


def test_resolve_task_provider_model_uses_custom_when_provider_is_auto():
"""When provider is auto, base_url+api_key should still resolve to custom."""
from agent.auxiliary_client import _resolve_task_provider_model

with patch(
"agent.auxiliary_client._get_auxiliary_task_config",
return_value={
"provider": "auto",
"model": "gpt-4o-mini",
"base_url": "https://example.com/v1",
"api_key": "sk-test",
},
):
provider, model, base_url, api_key, api_mode = _resolve_task_provider_model(task="vision")

assert provider == "custom"
assert model == "gpt-4o-mini"
assert base_url == "https://example.com/v1"
assert api_key == "sk-test"
assert api_mode is None
Loading