Skip to content

The agent that grows with you

fix(aux): caller thinking-off drops the task effort before the profile merge, never the profile's own disable

teknium16b1e960891cf
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py
index 2d7fa1dab5b..c70ad437918 100644
--- a/agent/auxiliary_client.py
+++ b/agent/auxiliary_client.py
@@ -6409,19 +6409,23 @@ def _merge_aux_extra_body(
) -> Dict[str, Any]:
"""Caller extra_body + profile body/reasoning + generic reasoning fallback + Nous tags."""
merged_extra = dict(extra_body or {})
+ caller_disabled = isinstance(reasoning_config, dict) and reasoning_config.get("enabled") is False
+ if caller_disabled:
+ # The caller's thinking-off beats ``auxiliary.<task>.reasoning_effort`` (folded into
+ # ``extra_body.reasoning`` by _get_task_extra_body). Dropped BEFORE the profile merge so a
+ # profile that projects disabled reasoning onto its own wire (custom: top-level
+ # ``reasoning_effort=none``) never ships beside a task-level ``reasoning.effort`` — strict
+ # gateways 400 on the contradiction (#114020) — while a profile whose disabled shape IS
+ # ``extra_body.reasoning`` (OpenRouter) still lands it below.
+ merged_extra.pop("reasoning", None)
merged_extra.update(projection.body)
merged_extra.update(projection.reasoning_extra)
if reasoning_config and isinstance(reasoning_config, dict) and not projection.handles_reasoning:
- if reasoning_config.get("enabled") is False:
+ if caller_disabled:
merged_extra["reasoning"] = {"enabled": False}
else:
# ``reasoning_config`` is already clamped to the OpenAI-compat wire by _build_call_kwargs.
merged_extra["reasoning"] = {"enabled": True, "effort": reasoning_config.get("effort") or "medium"}
- elif reasoning_config and isinstance(reasoning_config, dict) and reasoning_config.get("enabled") is False:
- # A reasoning-aware profile has already projected disabled reasoning to its own wire
- # (for example, ``reasoning_effort=none``). Task-level extra_body must not reintroduce
- # generic OpenAI reasoning alongside that profile-specific control.
- merged_extra.pop("reasoning", None)
# Caller/task ``extra_body.reasoning`` (``auxiliary.<task>.reasoning_effort`` folds in here via
# _get_task_extra_body) takes the same wire clamp: Hermes-only ``ultra`` never reaches the
# OpenAI-compat wire from any aux task (#112010).
diff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.py
index 83af361b087..fcb8028ab5a 100644
--- a/tests/agent/test_auxiliary_client.py
+++ b/tests/agent/test_auxiliary_client.py
@@ -2525,6 +2525,27 @@ class TestAuxiliaryTaskExtraBody:
assert "reasoning" not in kwargs["extra_body"]
assert kwargs["extra_body"]["metadata"] == {"task": "title"}
+ def test_disabled_caller_reasoning_keeps_profile_owned_disable_shape(self, monkeypatch):
+ """Control: a profile whose disabled shape IS ``extra_body.reasoning`` (OpenRouter) keeps it —
+ the caller's thinking-off replaces the task effort, it never deletes the profile's own field."""
+ import agent.auxiliary_client as aux
+
+ projection = aux._ProfileProjection({}, {"reasoning": {"enabled": False}}, {}, True)
+ monkeypatch.setattr(aux, "_project_provider_profile", lambda *_args: projection)
+ monkeypatch.setattr(aux, "_get_auxiliary_task_config", lambda _task: {"reasoning_effort": "low"})
+
+ kwargs = aux._build_call_kwargs(
+ provider="openrouter",
+ model="test-model",
+ messages=[{"role": "user", "content": "hello"}],
+ extra_body=aux._get_task_extra_body("title_generation"),
+ reasoning_config={"enabled": False},
+ task="title_generation",
+ )
+
+ assert kwargs["extra_body"]["reasoning"] == {"enabled": False}
+ assert "reasoning_effort" not in kwargs
+
@pytest.mark.parametrize("task", ["session_search", "moa_reference", "moa_aggregator"])
def test_generic_reasoning_fallback_clamps_ultra_for_auxiliary_and_moa_calls(self, task, monkeypatch):
"""The OpenAI-compatible fallback must never put Hermes-only ``ultra`` on the wire."""