The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(delegation): a backend's settings live under delegation.backends.<name>
Teknium37bdf15b4da3
diff --git a/agent/delegation_provider.py b/agent/delegation_provider.pyindex 3737db7bca4..abf8f27e7b2 100644--- a/agent/delegation_provider.py+++ b/agent/delegation_provider.py@@ -23,6 +23,9 @@ Route vocabulary (:meth:`DelegationProvider.route_task` returns a dict with anyscope helpers a multiplexed gateway uses for a routed turn. A profile route ignores the otherroute keys; the profile's own config decides them.* ``label`` - short text shown with the child's progress and result (e.g. the option title).++A backend's own settings live under ``delegation.backends.<backend name>`` (:meth:`DelegationProvider.settings`),+never beside the core ``delegation`` keys."""from __future__ import annotations@@ -56,10 +59,16 @@ class DelegationProvider(ProviderBase):"""Abstract base class for a pluggable delegation strategy.:attr:`name` is the ``delegation.backend`` value. Every method receives ``config``, the- ``delegation`` section of the active profile's config.yaml (read-only), so provider settings- live next to the other delegation knobs (``delegation.model_map``, ``delegation.profiles``).+ ``delegation`` section of the active profile's config.yaml (read-only): ``dict(config)`` is the+ default route, and :meth:`settings` is this backend's own block, ``delegation.backends.<name>``."""+ def settings(self, config: Mapping[str, Any]) -> Mapping[str, Any]:+ """This backend's settings: ``delegation.backends.<name>`` (empty when unset or not a mapping)."""+ backends = config.get("backends") if isinstance(config, Mapping) else None+ own = backends.get(self.name) if isinstance(backends, Mapping) else None+ return own if isinstance(own, Mapping) else {}+def is_available(self) -> bool:"""Whether this provider can run here. MUST NOT make network calls; False -> ``default``."""return Truediff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.pyindex 23e95e8fbf6..63ff490ee73 100644--- a/hermes_cli/config_defaults.py+++ b/hermes_cli/config_defaults.py@@ -1338,10 +1338,10 @@ DEFAULT_CONFIG = {# hindsight, supermemory, mem0, openviking, holographic). Empty = built-in only."provider": "",},- # Subagent delegation. `backend` = the strategy plugin routing each delegate_task task ("default": the keys- # below, else the parent's route); the provider:model pin uses the CLI/gateway runtime provider resolution.+ # Subagent delegation: `backend` = task-routing strategy ("default": keys below), `backends.<name>` = its settings."delegation": {"backend": "default",+ "backends": {},"model": "", # e.g. "google/gemini-3-flash-preview" (empty = inherit parent)"provider": "", # e.g. "openrouter" (empty = inherit parent provider + credentials)# Fallback chain for delegated children (same entry format as the top-level list).diff --git a/tests/tools/test_delegation_backends.py b/tests/tools/test_delegation_backends.pyindex 5ded5d9bc8b..74a3e49f020 100644--- a/tests/tools/test_delegation_backends.py+++ b/tests/tools/test_delegation_backends.py@@ -22,7 +22,7 @@ class Options(DelegationProvider):return "probe-options"def task_parameters(self, config):- opts = config.get("probe_options") or []+ opts = self.settings(config).get("options") or []return {"option": {"type": "string", "enum": [o["name"] for o in opts],"description": "; ".join(f"{o['name']}: {o['description']}" for o in opts)}}@@ -32,7 +32,7 @@ class Options(DelegationProvider):def route_task(self, task, config):if task.get("option") == "refused":raise DelegationRouteError("that option is reserved for humans")- for o in config.get("probe_options") or []:+ for o in self.settings(config).get("options") or []:if o["name"] == task.get("option"):return {"base_url": o["base_url"], "api_key": "k-" + o["name"], "model": o["model"],"reasoning_effort": o.get("reasoning_effort"), "label": o["name"]}@@ -100,7 +100,7 @@ def _parent():def test_selected_plugin_backend_extends_schema_and_routes_each_task(tmp_path, monkeypatch, recorded):- _, manager = _home(tmp_path, monkeypatch, {"backend": "probe-options", "probe_options": OPTIONS})+ _, manager = _home(tmp_path, monkeypatch, {"backend": "probe-options", "backends": {"probe-options": {"options": OPTIONS}}})try:from agent.delegation_registry import get_active_providerfrom tools.delegate_tool import delegate_task@@ -132,7 +132,7 @@ def test_selected_plugin_backend_extends_schema_and_routes_each_task(tmp_path, mdef test_model_supplied_parameters_are_enforced_before_any_child_is_built(tmp_path, monkeypatch, recorded):- _, manager = _home(tmp_path, monkeypatch, {"backend": "probe-options", "probe_options": OPTIONS})+ _, manager = _home(tmp_path, monkeypatch, {"backend": "probe-options", "backends": {"probe-options": {"options": OPTIONS}}})try:from tools.delegate_tool import delegate_task@@ -238,3 +238,14 @@ def test_backend_key_reads_through_the_real_loader(tmp_path, monkeypatch):assert configured_backend(_load_config()) == "probe-options"finally:manager.unload()+++def test_backend_settings_come_from_its_own_backends_block(tmp_path, monkeypatch):+ """A backend's settings are ``delegation.backends.<its name>``: the same keys beside the core delegation keys+ or under another backend's name are not its settings."""+ _, manager = _home(tmp_path, monkeypatch, {"backend": "probe-options", "options": OPTIONS,+ "backends": {"model_map": {"options": OPTIONS}}})+ try:+ assert _task_props(_definition())["option"]["enum"] == []+ finally:+ manager.unload()