fix: retain reasoning effort on named custom provider routes

Apply the narrow registry fallback proposed in PR #68458 without unrelated case normalization or dead legacy flags. Preserve dedicated named profiles before using CustomProfile. This corrects existing reasoning loss only; per-model dialect configuration remains a product decision.

Co-authored-by: saotu <160758706+saotu@users.noreply.github.com>
This commit is contained in:
Teknium
2026-09-07 02:16:50 -07:00
parent 8d4b7414a0
commit bcef8d66d3
2 changed files with 36 additions and 1 deletions

View File

@@ -75,7 +75,12 @@ def get_provider_profile(name: str) -> ProviderProfile | None:
if not _discovered:
_discover_providers()
canonical = _ALIASES.get(name, name)
return _REGISTRY.get(canonical)
profile = _REGISTRY.get(canonical)
# Named custom routes share the generic wire policy unless a plugin
# explicitly registered that route. Other names retain exact lookup.
if profile is None and isinstance(name, str) and name.lower().startswith("custom:"):
profile = _REGISTRY.get("custom")
return profile
def list_providers() -> list[ProviderProfile]:

View File

@@ -0,0 +1,30 @@
"""Named custom routes use the same reasoning contract as bare custom."""
from providers import get_provider_profile, register_provider
from providers.base import ProviderProfile
from agent.transports.chat_completions import ChatCompletionsTransport
def test_named_custom_route_keeps_final_reasoning_effort():
transport = ChatCompletionsTransport()
for effort in ("low", "medium", "high"):
outputs = [transport.build_kwargs(
"fixture-model", [{"role": "user", "content": "fixture"}],
provider_profile=get_provider_profile(provider),
base_url="http://127.0.0.1:1/v1",
reasoning_config={"enabled": True, "effort": effort},
) for provider in ("custom", "custom:fixture")]
assert outputs[0]["reasoning_effort"] == effort
assert outputs[1] == outputs[0]
def test_named_custom_fallback_does_not_override_registered_routes(monkeypatch):
import providers
get_provider_profile("custom")
monkeypatch.setattr(providers, "_REGISTRY", dict(providers._REGISTRY))
monkeypatch.setattr(providers, "_ALIASES", dict(providers._ALIASES))
monkeypatch.setattr(providers, "_PROVIDER_LIST_CACHE", None)
dedicated = ProviderProfile(name="custom:fixture")
register_provider(dedicated)
assert get_provider_profile("custom:fixture") is dedicated
assert get_provider_profile("CUSTOM:unregistered") is get_provider_profile("custom")
assert get_provider_profile("NONEXISTENT") is None