Skip to content
Closed
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
6 changes: 5 additions & 1 deletion agent/auxiliary_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ def _normalize_aux_provider(provider: Optional[str]) -> str:
suffix = normalized.split(":", 1)[1].strip()
if not suffix:
return "custom"
normalized = suffix
# Preserve named custom providers (``custom:<name>``) through routing.
# Dropping the prefix makes auxiliary/vision routes look for a bare
# provider name and can fall back to the default custom endpoint instead
# of the explicitly selected custom provider.
normalized = f"custom:{suffix}"
if normalized == "codex":
return "openai-codex"
if normalized == "main":
Expand Down
30 changes: 30 additions & 0 deletions tests/agent/test_auxiliary_main_first.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,36 @@ def test_explicit_provider_override_still_wins(self):
assert provider == "nous"
mock_strict.assert_called_once_with("nous", None)

def test_named_custom_provider_override_preserves_custom_prefix(self):
"""Explicit custom:<name> vision overrides route to that named provider."""
with patch(
"agent.auxiliary_client._read_main_provider", return_value="openrouter",
), patch(
"agent.auxiliary_client._read_main_model",
return_value="anthropic/claude-opus-4.6",
), patch(
"agent.auxiliary_client._resolve_task_provider_model",
return_value=("custom:morecode-openai", "vision-model", None, None, None),
), patch(
"agent.auxiliary_client.resolve_provider_client"
) as mock_resolve, patch(
"agent.auxiliary_client._resolve_strict_vision_backend"
) as mock_strict:
mock_client = MagicMock()
mock_resolve.return_value = (mock_client, "vision-model")

from agent.auxiliary_client import resolve_vision_provider_client

provider, client, model = resolve_vision_provider_client()

assert provider == "custom:morecode-openai"
assert client is mock_client
assert model == "vision-model"
mock_resolve.assert_called_once()
assert mock_resolve.call_args.args[0] == "custom:morecode-openai"
assert mock_resolve.call_args.kwargs.get("is_vision") is True
mock_strict.assert_not_called()


# ── Constant cleanup ────────────────────────────────────────────────────────

Expand Down