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:
@@ -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]:
|
||||
|
||||
30
tests/providers/test_named_custom_reasoning.py
Normal file
30
tests/providers/test_named_custom_reasoning.py
Normal 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
|
||||
Reference in New Issue
Block a user