The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(delegation): an unknown reasoning_effort on a backend route is a tool error
Tekniumeece3e2e9e23
diff --git a/agent/delegation_provider.py b/agent/delegation_provider.pyindex 6f73d15da7a..98bf3527321 100644--- a/agent/delegation_provider.py+++ b/agent/delegation_provider.py@@ -17,7 +17,8 @@ Route vocabulary (:meth:`DelegationProvider.route_task` returns a dict with any* ``model``, ``provider``, ``base_url``, ``api_key``, ``api_mode``, ``request_overrides``,``reasoning_effort``, ``fallback_providers`` - shaped exactly like the ``delegation`` configsection and resolved by the same credential resolver ``delegation.*`` uses (empty route = the- child inherits the parent's route, like an empty ``delegation`` section).+ child inherits the parent's route, like an empty ``delegation`` section). An unknown+ ``reasoning_effort`` refuses the task.* ``service_tier`` - ``normal``, ``fast`` or ``ultrafast``, checked like ``/fast`` against theresolved route (and, for ultrafast, the Codex account); a tier the route does not offer refusesthe task, and the tier is re-applied after the child is built.diff --git a/tests/tools/test_delegation_route_fields.py b/tests/tools/test_delegation_route_fields.pyindex 685c18ec238..377b2671552 100644--- a/tests/tools/test_delegation_route_fields.py+++ b/tests/tools/test_delegation_route_fields.py@@ -118,3 +118,14 @@ def test_default_backend_never_reads_a_tier_from_the_delegation_section():result, (child,), _ = _spawn([None], cfg={**CODEX, "service_tier": "fast"}, provider=get_active_provider({}))assert result == {"status": "built"}assert child.get("service_tier") is None and "service_tier" not in child["request_overrides"]+++def test_unknown_route_reasoning_effort_is_a_tool_error_not_the_parents_level():+ result, built, _ = _spawn([{**LOCAL, "reasoning_effort": "hgih"}, None])+ assert "hgih" in result["error"] and "xhigh" in result["error"] and built == []+++def test_the_delegation_sections_own_effort_keeps_its_warn_and_inherit_rule():+ """A backend that falls back to ``dict(config)`` carries the config's value; config behaviour is unchanged."""+ result, (child,), _ = _spawn([None], cfg={"reasoning_effort": "hgih"})+ assert result == {"status": "built"} and child["reasoning_config"] == {"enabled": True, "effort": "medium"}diff --git a/tools/delegate_tool_routes.py b/tools/delegate_tool_routes.pyindex d3f6fae3164..2d06e00ccbc 100644--- a/tools/delegate_tool_routes.py+++ b/tools/delegate_tool_routes.py@@ -224,6 +224,19 @@ def _route_to_task_route(route: dict[str, Any], parent_agent: Any, cache: dict[sreturn replace(cache[key], label=label)+def _check_backend_effort(index: int, route: Mapping[str, Any], config: Mapping[str, Any]) -> None:+ """A backend's ``reasoning_effort`` must be a known level: a typo is a tool error, never the parent's level.+ The ``delegation`` section's own value (a backend returning ``dict(config)``) keeps its warn-and-inherit rule."""+ effort = route.get("reasoning_effort")+ if route.get("profile") or effort in (None, "") or effort == config.get("reasoning_effort"):+ return+ from hermes_constants import VALID_REASONING_EFFORTS, parse_reasoning_effort+ if parse_reasoning_effort(effort) is None:+ raise DelegationRouteError(+ f"Task {index}: unknown reasoning_effort {effort!r} on this route. "+ f"Use none or one of: {', '.join(VALID_REASONING_EFFORTS)}.")++def _route_one(provider: DelegationProvider, declared: dict[str, dict[str, Any]], index: int,task: Mapping[str, Any], config: Mapping[str, Any]) -> dict[str, Any]:params = {name: task[name] for name in declared if task.get(name) is not None}@@ -255,7 +268,9 @@ def resolve_task_routes(task_list: list[dict[str, Any]], config: Mapping[str, Antry:for i, task in enumerate(task_list):route = _route_one(provider, declared, i, task, config)- if not from_backend:+ if from_backend:+ _check_backend_effort(i, route, config)+ else:route.pop("service_tier", None) # not a delegation-section key: the default route stays today'sroutes.append(_route_to_task_route(route, parent_agent, cache))except ValueError as exc: # DelegationRouteError, the credential resolver's and the tier check's refusals