Skip to content

The agent that grows with you

fix(custom): declare the OpenAI-compat effort vocabulary so Responses keeps a configured max

liuhao1024f111297af194
diff --git a/plugins/model-providers/custom/__init__.py b/plugins/model-providers/custom/__init__.py
index 31ac558171c..01909ebd074 100644
--- a/plugins/model-providers/custom/__init__.py
+++ b/plugins/model-providers/custom/__init__.py
@@ -29,6 +29,19 @@ def _looks_like_ollama_endpoint(base_url: str | None) -> bool:
class CustomProfile(ProviderProfile):
"""Custom/Ollama local provider — think=false and num_ctx support."""
+ def supported_reasoning_efforts(self, model: str | None) -> tuple[str, ...]:
+ """The OpenAI-compat wire set, mirroring this profile's own chat-completions clamp.
+
+ Without this declaration the Responses transport clamps onto the OpenAI
+ per-model ladder (``codex_supported_efforts``), where ``max`` is gpt-5.6-only —
+ so a custom relay's model had a configured ``max`` silently demoted to
+ ``xhigh`` while the same provider over chat-completions forwarded ``max``
+ unchanged (#114249). A custom endpoint's vocabulary is undiscoverable, so
+ the widest OpenAI-compat set is the honest ceiling; ``ultra`` still clamps
+ to ``max`` via the shared ``clamp_effort`` policy.
+ """
+ return OPENAI_COMPAT_WIRE_EFFORTS
+
def build_api_kwargs_extras(
self, *, reasoning_config: dict | None = None, ollama_num_ctx: int | None = None, **ctx: Any
) -> tuple[dict[str, Any], dict[str, Any]]:
diff --git a/tests/plugins/model_providers/test_custom_profile.py b/tests/plugins/model_providers/test_custom_profile.py
index 72ca95f1cc0..a3ba59733b4 100644
--- a/tests/plugins/model_providers/test_custom_profile.py
+++ b/tests/plugins/model_providers/test_custom_profile.py
@@ -180,3 +180,70 @@ class TestCustomReasoningWithNumCtx:
assert eb == {"options": {"num_ctx": 8192}}
assert tl == {}
+
+class TestCustomResponsesEffortVocabulary:
+ """``supported_reasoning_efforts`` keeps the two transports consistent (#114249).
+
+ A custom relay's models are not on the OpenAI per-model ladder, so before
+ this declaration the Responses transport clamped a configured ``max`` down
+ to ``xhigh`` (CODEX_LEGACY_EFFORTS) while the same provider over
+ chat-completions forwarded ``max`` unchanged.
+ """
+
+ def test_declares_openai_compat_wire_set(self, custom_profile):
+ from agent.reasoning_effort import OPENAI_COMPAT_WIRE_EFFORTS
+
+ declared = custom_profile.supported_reasoning_efforts("deepseek-flash")
+ assert declared == OPENAI_COMPAT_WIRE_EFFORTS
+ assert "max" in declared
+
+ def test_named_custom_route_resolves_to_the_declaration(self, custom_profile):
+ """``custom:<name>`` resolves to this profile through the registry's
+ custom-route fallback, so named relays inherit the same vocabulary."""
+ import providers
+
+ named = providers.get_provider_profile("custom:relay")
+ assert named is custom_profile
+
+ def test_responses_transport_keeps_configured_max(self):
+ from agent.transports.codex import _resolve_reasoning
+
+ effort, enabled = _resolve_reasoning(
+ "deepseek-flash",
+ {
+ "provider": "custom:relay",
+ "base_url": "https://relay.example/v1",
+ "reasoning_config": {"enabled": True, "effort": "max"},
+ },
+ )
+ assert (effort, enabled) == ("max", True)
+
+ def test_responses_transport_still_clamps_ultra_to_max(self):
+ """``ultra`` is Hermes-internal; even the widest declared wire set
+ must not pass it through verbatim."""
+ from agent.transports.codex import _resolve_reasoning
+
+ effort, _ = _resolve_reasoning(
+ "deepseek-flash",
+ {
+ "provider": "custom:relay",
+ "base_url": "https://relay.example/v1",
+ "reasoning_config": {"enabled": True, "effort": "ultra"},
+ },
+ )
+ assert effort == "max"
+
+ def test_openai_backend_ladder_is_unchanged(self):
+ """The declaration must not leak into the official OpenAI Responses
+ backend: gpt-5.5 keeps rejecting ``max`` (clamps to xhigh, #68365)."""
+ from agent.transports.codex import _resolve_reasoning
+
+ effort, enabled = _resolve_reasoning(
+ "gpt-5.5",
+ {
+ "provider": "openai",
+ "reasoning_config": {"enabled": True, "effort": "max"},
+ },
+ )
+ assert (effort, enabled) == ("xhigh", True)
+