Skip to content

The agent that grows with you

feat(delegation): a session routes on the backend its delegate_task was built from

Teknium4b6c7f68d974
diff --git a/acp_adapter/server.py b/acp_adapter/server.py
index 8baa96fc0e6..0befc4ca49f 100644
--- a/acp_adapter/server.py
+++ b/acp_adapter/server.py
@@ -452,6 +452,8 @@ class HermesACPAgent(SlashCommandsMixin, acp.Agent):
getattr(agent, "enabled_toolsets", None),
mcp_server_names=[s.name for s in mcp_servers],
)
+ from agent.delegation_backends import saved_backend
+ agent._delegation_backend = saved_backend() # the session routes on what its delegate_task is built from
agent.tools = get_tool_definitions(
enabled_toolsets=agent.enabled_toolsets,
disabled_toolsets=getattr(agent, "disabled_toolsets", None), quiet_mode=True,
diff --git a/agent/agent_init.py b/agent/agent_init.py
index 59006475ded..ee1aedc9521 100644
--- a/agent/agent_init.py
+++ b/agent/agent_init.py
@@ -1106,12 +1106,11 @@ def _load_tools(agent, enabled_toolsets, disabled_toolsets):
except Exception:
logger.warning("Plugin discovery failed during agent setup", exc_info=True)
- # Capture the registry generation FIRST so a concurrent refresh can detect staleness.
- try:
- from tools.registry import registry as _snapshot_registry
- agent._tool_snapshot_generation = _snapshot_registry._generation
- except Exception:
- agent._tool_snapshot_generation = 0
+ # Capture the registry generation FIRST so a concurrent refresh can detect staleness, and the delegation
+ # backend this delegate_task is built from: the session routes on it (agent/delegation_backends.py).
+ from agent.delegation_backends import saved_backend
+ from tools.registry import registry as _snapshot_registry
+ agent._tool_snapshot_generation, agent._delegation_backend = _snapshot_registry._generation, saved_backend()
import model_tools
from toolsets import agent_tool_drops, session_disabled_toolsets
disabled_toolsets = session_disabled_toolsets(disabled_toolsets, getattr(agent, "platform", None))
diff --git a/agent/delegation_backends.py b/agent/delegation_backends.py
index 1c3237904a6..b6064d1c244 100644
--- a/agent/delegation_backends.py
+++ b/agent/delegation_backends.py
@@ -1,11 +1,12 @@
"""Which delegation backend Hermes uses: the public API behind a ``/delegation`` command.
-``delegation.backend`` in config.yaml is the one choice; ``delegate_task`` reads it at every call. The
-``delegate_task`` schema (a backend's per-task parameters) is part of the cached prompt, so a switch reaches a
-session's tool list from its next session (``/new``). ``apply_now`` opts into rebuilding the calling session's
-tools at its next turn instead: one prompt-cache break, the rule every slash command that changes prompt state
-follows (``--now``). Until then a task carrying parameters the saved backend does not declare is refused
-(``tools/delegate_tool_routes.py``), never run on the new backend's default route.
+``delegation.backend`` in config.yaml is the saved choice. A session routes on the backend its ``delegate_task``
+schema was built from (``agent._delegation_backend``, captured with its tools and pinned with them to the session
+row), because that schema (a backend's per-task parameters) is cached prompt: a save, or a config.yaml edit,
+changes nothing in a running chat and applies from its next session (``/new``). ``apply_now`` opts into
+rebuilding the calling session's tools at its next turn instead, so routing and schema switch together there:
+one prompt-cache break, the rule every slash command that changes prompt state follows (``--now``). A task
+carrying parameters its session's backend does not declare is still refused (``tools/delegate_tool_routes.py``).
Session keys are the ``session_key`` a plugin command handler receives: the gateway/TUI route key, or the
session id on the classic in-process CLI. A turn resolves the same key from its session context, else from the
@@ -18,7 +19,7 @@ import threading
from dataclasses import asdict, dataclass
from typing import Any
-from agent.delegation_registry import DEFAULT_BACKEND, _registry, backend_status
+from agent.delegation_registry import DEFAULT_BACKEND, _registry, backend_status, configured_backend
from agent.provider_registry import lower_key
_rebuild_requests: set[str] = set()
@@ -49,11 +50,36 @@ def list_backends() -> list[BackendInfo]:
return [_info(name) for name in names]
+def saved_backend() -> str:
+ """``delegation.backend`` as config.yaml has it now: what a tool build reads."""
+ from tools.delegate_tool_config import _load_config
+ return configured_backend(_load_config())
+
+
+def _delegate_def(tools: Any) -> Any:
+ return next((t for t in tools or () if isinstance(t, dict)
+ and (t.get("function") or {}).get("name") == "delegate_task"), None)
+
+
+def adopt_built_backend(agent: Any, defs: Any, backend: str) -> None:
+ """Record ``backend`` as the session's when the agent's ``delegate_task`` is the one ``defs`` carries (built
+ from ``backend``, or pinned with it); a kept older definition keeps the backend it was built from."""
+ if _delegate_def(getattr(agent, "tools", None)) == _delegate_def(defs):
+ agent._delegation_backend = backend
+
+
+def pinned_backend(agent: Any) -> str:
+ """The backend ``agent``'s ``delegate_task`` was built from; ``""`` for no agent (or one never built), whose
+ tasks route on config.yaml's."""
+ pinned = getattr(agent, "_delegation_backend", None)
+ return pinned if isinstance(pinned, str) else ""
+
+
def set_global_backend(name: str, *, session_key: str = "", apply_now: bool = False) -> None:
"""Persist ``delegation.backend`` to the active profile's config.yaml (raw user config, never merged
- defaults). ``apply_now`` also rebuilds ``session_key``'s tool list at that session's next turn, so its
- ``delegate_task`` offers the new backend's parameters there (an opt-in prompt-cache break); otherwise a
- session's tools pick the switch up from ``/new``. Raises ``PermissionError`` on a package-manager-managed
+ defaults). Running sessions keep routing on the backend their tools were built from; ``apply_now`` rebuilds
+ ``session_key``'s tools at that session's next turn, so it routes on and offers the new backend's parameters
+ from there (an opt-in prompt-cache break); otherwise sessions pick the switch up from ``/new``. Raises ``PermissionError`` on a package-manager-managed
install (its config.yaml is not ours to write) and ``ValueError`` (with the reason) for a backend that cannot
run or an ``apply_now`` without a session, before anything is written."""
from hermes_cli.config import (
@@ -85,9 +111,9 @@ def _current_session_key(agent: Any) -> str:
def apply_requested_tool_rebuild(agent: Any) -> bool:
- """Turn start, after the session's tools are restored: rebuild ``agent.tools`` from the registry if
- ``set_global_backend(apply_now=True)`` asked for this session, and pin the result to the session row so a
- later fresh agent restores it. True when the tool list changed. Forks (background review, ``/btw``) and
+ """Turn start, after the session's tools are restored: rebuild ``agent.tools`` (and with it the backend the
+ session routes on) if ``set_global_backend(apply_now=True)`` asked for this session, and pin both to the
+ session row so a later fresh agent restores them. True when the tool list changed. Forks (background review, ``/btw``) and
subagents share the session's key but never take its request."""
if getattr(agent, "_turn_origin", None) or getattr(agent, "_delegate_depth", 0):
return False
@@ -99,10 +125,10 @@ def apply_requested_tool_rebuild(agent: Any) -> bool:
from hermes_cli.observability.shared_metrics_efficiency import record_cache_break
from tools.mcp_tool_agent import persist_agent_tool_names, refresh_agent_mcp_tools
before = getattr(agent, "tools", None)
- refresh_agent_mcp_tools(agent, quiet_mode=True, content_aware=True)
+ refresh_agent_mcp_tools(agent, quiet_mode=True, content_aware=True) # adopts the saved backend
+ persist_agent_tool_names(agent) # also when only the backend moved (two backends, one schema)
if agent.tools is before:
return False
- persist_agent_tool_names(agent)
record_cache_break(agent, "toolset_change")
return True
diff --git a/agent/delegation_registry.py b/agent/delegation_registry.py
index 19e2d0f9453..ff530f0e9a8 100644
--- a/agent/delegation_registry.py
+++ b/agent/delegation_registry.py
@@ -5,7 +5,7 @@ asks :func:`get_active_provider` which strategy turns each task into a child run
``delegation.backend`` in config.yaml, ``default`` when unset. The default strategy (today's
behaviour: every child follows the ``delegation`` section, else the parent's route) is itself a
plugin, the bundled ``plugins/delegation/default``, registered through the same seam as any other.
-``agent/delegation_backends.py`` switches it (``/delegation``). A configured backend that is
+``agent/delegation_backends.py`` saves it (``/delegation``); a session routes on the backend its tools were built from. A configured backend that is
not registered or reports unavailable fails closed: ``delegate_task`` returns a tool error naming the
backend and the fix, and never quietly runs the children on another route. Its schema parameters are
absent, since the schema is built from the same resolution.
diff --git a/tests/agent/test_delegation_switch_next_session.py b/tests/agent/test_delegation_switch_next_session.py
index 446d4002a2e..45f9c296917 100644
--- a/tests/agent/test_delegation_switch_next_session.py
+++ b/tests/agent/test_delegation_switch_next_session.py
@@ -1,7 +1,9 @@
"""``/delegation <backend>`` saves for the next session; ``--now`` rebuilds this session's tools.
-Real AIAgent turns against a recording fake provider, a real delegation backend plugin discovered from a temp
-HERMES_HOME, and the real session DB: each test reads the ``delegate_task`` schema Hermes actually sent.
+A session routes on the backend its ``delegate_task`` schema was built from, so routing and schema switch
+together. Real AIAgent turns against a recording fake provider, a real delegation backend plugin discovered from
+a temp HERMES_HOME and the real session DB: each test reads the schema Hermes actually sent and the backend a
+task with no choice routes on.
"""
from __future__ import annotations
@@ -47,9 +49,10 @@ def _agent(srv, home, session_id):
from hermes_state import SessionDB
from run_agent import AIAgent
+ db = SessionDB(db_path=home / "state.db")
+ db.ensure_session(session_id, source="cli") # opened before its first turn, as the gateway does
return AIAgent(provider="custom", base_url=srv.base_url, api_key="sk-fake-e2e", model="fake-model",
- session_db=SessionDB(db_path=home / "state.db"), session_id=session_id, quiet_mode=True,
- platform="cli")
+ session_db=db, session_id=session_id, quiet_mode=True, platform="cli")
def _sent_task_fields(srv) -> set[str]:
@@ -58,31 +61,42 @@ def _sent_task_fields(srv) -> set[str]:
return set(tool["function"]["parameters"]["properties"]["tasks"]["items"]["properties"])
+def _routed_on(agent) -> str:
+ """The backend a task naming no option routes on for ``agent``'s session."""
+ from tools.delegate_tool_config import _load_config
+ from tools.delegate_tool_routes import resolve_task_routes
+ routes, error = resolve_task_routes([{"goal": "a plain task"}], _load_config(), agent)
+ assert error is None
+ return routes[0].backend
+
+
def _turn(agent, text, history):
return agent.run_conversation(text, conversation_history=history, task_id="t")["messages"]
-def test_a_now_switch_rebuilds_this_sessions_delegate_task_for_the_new_backend(options_backend):
+def test_a_now_switch_rebuilds_this_sessions_delegate_task_and_routing_for_the_new_backend(options_backend):
from agent.delegation_backends import set_global_backend
srv, home = options_backend
agent = _agent(srv, home, "chat-now")
history = _turn(agent, "hello", [])
- assert "option" in _sent_task_fields(srv)
+ assert "option" in _sent_task_fields(srv) and _routed_on(agent) == "probe-options"
set_global_backend("default", session_key="chat-now", apply_now=True)
history = _turn(agent, "and now", history)
- assert "option" not in _sent_task_fields(srv)
+ assert "option" not in _sent_task_fields(srv) and _routed_on(agent) == "default"
agent.close()
- # The rebuilt tools are the session's pin: a fresh agent on it (gateway, --resume) restores them.
+ # The rebuilt tools and their backend are the session's pin: a fresh agent on it (gateway, --resume) restores
+ # both, whatever config.yaml says by then.
+ set_global_backend("probe-options")
fresh = _agent(srv, home, "chat-now")
_turn(fresh, "still here", history)
+ assert "option" not in _sent_task_fields(srv) and _routed_on(fresh) == "default"
fresh.close()
- assert "option" not in _sent_task_fields(srv)
-def test_a_plain_switch_keeps_this_sessions_schema_and_new_sessions_take_the_saved_backend(options_backend):
+def test_a_plain_switch_changes_nothing_in_this_session_and_new_sessions_take_the_saved_backend(options_backend):
import hermes_yaml as yaml
from agent.delegation_backends import set_global_backend
@@ -93,11 +107,16 @@ def test_a_plain_switch_keeps_this_sessions_schema_and_new_sessions_take_the_sav
set_global_backend("default", session_key="chat-plain")
assert yaml.safe_load((home / "config.yaml").read_text())["delegation"]["backend"] == "default"
- _turn(agent, "and now", history)
+ history = _turn(agent, "and now", history)
assert srv.main_requests()[-1]["tools"] == before # the cached tool list is untouched
+ assert _routed_on(agent) == "probe-options" # and so is the backend it routes on
agent.close()
+ resumed = _agent(srv, home, "chat-plain") # a fresh agent on the same session restores both
+ _turn(resumed, "still here", history)
+ assert srv.main_requests()[-1]["tools"] == before and _routed_on(resumed) == "probe-options"
+ resumed.close()
new = _agent(srv, home, "chat-plain-new") # /new
_turn(new, "hello again", [])
+ assert "option" not in _sent_task_fields(srv) and _routed_on(new) == "default"
new.close()
- assert "option" not in _sent_task_fields(srv)
diff --git a/tests/tools/test_delegation_backends.py b/tests/tools/test_delegation_backends.py
index d315a09f575..2cb987281a9 100644
--- a/tests/tools/test_delegation_backends.py
+++ b/tests/tools/test_delegation_backends.py
@@ -209,9 +209,9 @@ def test_a_backend_route_without_its_own_chain_inherits_delegation_fallback_prov
def test_a_saved_switch_refuses_the_previous_backends_parameter_and_names_the_fix(tmp_path, monkeypatch, recorded):
- """``/delegation <backend>`` saves config.yaml and routing follows it at once, while a running session's
- schema (cached prompt) still offers the previous backend's parameters: a task sending one is refused alone,
- naming the backend, the parameter and the fix; it never runs on the new backend's default route."""
+ """``/delegation <backend>`` saves config.yaml, and a parent with no tools of its own routes on it. A task
+ sending a parameter that backend does not declare is refused alone, naming the backend, the parameter and the
+ fix; it never runs on the backend's default route."""
from agent.delegation_provider import DelegationProvider
from agent.delegation_registry import _registry
diff --git a/tools/AGENTS.md b/tools/AGENTS.md
index 9e9ef9c5d91..9679a81399e 100644
--- a/tools/AGENTS.md
+++ b/tools/AGENTS.md
@@ -144,7 +144,7 @@ resolved like the `delegation` section, `service_tier` checked like `/fast` in `
the child is built, leases and converses inside that profile's scope) and may add enum-checked per-task schema params; it
never owns lifecycle. The `default` strategy is the bundled `plugins/delegation/default` plugin (no core special case
beyond selecting it). Fails closed: an unusable backend is a tool error naming it (never a silent `default`), an
-unroutable task is refused alone (`TaskRoute.error`), as is a task sending a parameter the saved backend lacks (a switch reaches a session's schema at `/new` or with `--now`: `agent/delegation_backends.py`). Internal `credentials_cfg` callers (/review) and the lifecycle API bypass it. **Child processes:** a child's background
+unroutable task is refused alone (`TaskRoute.error`), as is a task sending a parameter its backend lacks. A session routes on the backend its `delegate_task` was built from (`agent._delegation_backend`, pinned with its tools), so a save applies at `/new` or `--now` (`agent/delegation_backends.py`). Internal `credentials_cfg` callers (/review) and the lifecycle API bypass it. **Child processes:** a child's background
processes are killed at its teardown and their notices are suppressed in the parent; `process_manage(action="handoff")`
(children only) flips `ProcessSession.owner_task_id` to the parent under the registry lock
(`process_registry.transfer_ownership`) so the completion routes and reaps by the new owner; un-handed leftovers land on
diff --git a/tools/delegate_tool_routes.py b/tools/delegate_tool_routes.py
index 402ec5a5832..a2dfcf3a521 100644
--- a/tools/delegate_tool_routes.py
+++ b/tools/delegate_tool_routes.py
@@ -266,9 +266,9 @@ def _check_backend_effort(index: int, route: Mapping[str, Any], config: Mapping[
def _undeclared_error(provider: DelegationProvider, index: int, names: list[str], config: Mapping[str, Any]) -> str:
- """Why a task carrying parameters the saved backend does not declare is refused. The schema is cached prompt,
- so after a ``/delegation`` switch the session's tool list still offers the previous backend's parameters until
- ``/new`` or ``/delegation <backend> --now``; dropping them would run the task on this backend's default route."""
+ """Why a task carrying parameters the session's backend does not declare is refused (a model inventing them, or
+ a session whose tools came from another build than its backend); dropping them would run the task on this
+ backend's default route. ``/delegation <backend> --now`` or ``/new`` rebuilds the tools and the backend together."""
from agent.delegation_registry import _registry
active = provider.name
listed = ", ".join(f"'{name}'" for name in names)
@@ -308,10 +308,13 @@ def _route_one(provider: DelegationProvider, declared: dict[str, dict[str, Any]]
def resolve_task_routes(task_list: list[dict[str, Any]], config: Mapping[str, Any], parent_agent: Any,
) -> tuple[list[TaskRoute], Optional[str]]:
- """One :class:`TaskRoute` per task from ``delegation.backend``, or ``([], error)`` when that backend cannot
- run (fails closed, never another backend). A task the backend cannot route gets a route with ``error`` set;
- its siblings are unaffected. Identical routes resolve credentials once per call (the default backend
- resolves exactly once)."""
+ """One :class:`TaskRoute` per task from the backend the session's ``delegate_task`` was built from (else
+ ``delegation.backend``), or ``([], error)`` when that backend cannot run (fails closed, never another backend).
+ A task the backend cannot route gets a route with ``error`` set; its siblings are unaffected. Identical routes
+ resolve credentials once per call (the default backend resolves exactly once)."""
+ from agent.delegation_backends import pinned_backend
+ if pinned := pinned_backend(parent_agent):
+ config = {**config, "backend": pinned}
try:
provider = _active_provider(config)
except DelegationRouteError as exc:
diff --git a/tools/mcp_tool_agent.py b/tools/mcp_tool_agent.py
index e74f1510b57..7ab6217b1dd 100644
--- a/tools/mcp_tool_agent.py
+++ b/tools/mcp_tool_agent.py
@@ -123,6 +123,8 @@ def refresh_agent_mcp_tools(
# Generation captured BEFORE the slow get_tool_definitions call (a slower caller holding an
# OLDER set must not clobber a newer one); definitions computed OUTSIDE the lock.
snapshot_generation = registry._generation
+ from agent.delegation_backends import adopt_built_backend, saved_backend
+ built_backend = saved_backend()
new_defs = list(get_tool_definitions(enabled_toolsets=enabled, disabled_toolsets=disabled, quiet_mode=quiet_mode) or [])
new_names = {_def_name(t) for t in new_defs}
# Post-build families re-appended on LOCALS only; live attributes untouched until publish.
@@ -143,6 +145,8 @@ def refresh_agent_mcp_tools(
added = _publish_tool_snapshot(
agent, new_defs, new_names, snapshot_generation=snapshot_generation,
staged_engine_names=staged_engine_names, content_aware=content_aware, prefix_registered=prefix_registered)
+ if prefix_registered is None: # a rebuild: the session now routes on the backend its new delegate_task is from
+ adopt_built_backend(agent, new_defs, built_backend)
if added is None:
return set()
persist_agent_tool_names(agent) # re-pin so a rebuild after agent-cache eviction restores this order
@@ -176,7 +180,10 @@ def persist_agent_tool_names(agent) -> None:
if not db or not session_id:
return
try:
- db.update_session_tool_names(session_id, {"version": tool_pin_version(), "tools": _agent_tool_defs(agent)})
+ pin = {"version": tool_pin_version(), "tools": _agent_tool_defs(agent)}
+ if backend := getattr(agent, "_delegation_backend", None):
+ pin["delegation_backend"] = backend # what its delegate_task was built from: the session routes on it
+ db.update_session_tool_names(session_id, pin)
except Exception:
logger.debug("tool_names persist skipped", exc_info=True)
@@ -260,6 +267,9 @@ def restore_agent_tool_prefix(agent, saved) -> bool:
with _agent_tools_lock:
agent.tools = merged
agent.valid_tool_names = merged_names
+ if isinstance(saved, dict) and saved.get("delegation_backend"):
+ from agent.delegation_backends import adopt_built_backend
+ adopt_built_backend(agent, pinned, saved["delegation_backend"])
if not same_code or merged != list(pinned):
persist_agent_tool_names(agent)
return changed
diff --git a/website/docs/developer-guide/delegation-provider-plugin.md b/website/docs/developer-guide/delegation-provider-plugin.md
index f8487f6b5a1..d6095adc21f 100644
--- a/website/docs/developer-guide/delegation-provider-plugin.md
+++ b/website/docs/developer-guide/delegation-provider-plugin.md
@@ -168,14 +168,15 @@ A plugin command that edits model routes can reuse the interactive model picker
`hermes_cli.auth_model_picker.prompt_model_selection(model_ids, current_model="", title="Select the model for this route:")`
returns the chosen model id, or `None` when cancelled.
-`session_key` is the `session_key` a plugin command handler receives. `delegate_task` reads
-`delegation.backend` at every call, but its schema (your parameters) is part of the cached prompt, so a switch
-reaches a running session's tool list only from its next session (`/new`). `apply_now=True` (what
-`/delegation <backend> --now` passes) rebuilds that session's tools at its next turn instead, breaking the prompt
-cache once by the user's choice, the same opt-in as `/skills install --now`. Until one of those happens the model
-can still send the previous backend's parameters, so core refuses each task carrying a parameter the saved backend
-does not declare (fail closed per task, like any other refusal) instead of dropping it and running the task on the
-new backend's default route:
+`session_key` is the `session_key` a plugin command handler receives. A session routes on the backend its
+`delegate_task` schema (your parameters) was built from: core captures it with the session's tools and pins it
+with them to the session row, so a fresh agent continuing the session (gateway, `--resume`) restores both. The
+schema is part of the cached prompt, so a save, or a hand edit of `delegation.backend`, changes nothing in a running
+session and applies from its next session (`/new`). `apply_now=True` (what `/delegation <backend> --now` passes)
+rebuilds that session's tools at its next turn instead, and routing moves with them: one prompt-cache break by the
+user's choice, the same opt-in as `/skills install --now`. Context compression rebuilds the tools anyway and picks up
+the saved backend. A task carrying a parameter its session's backend does not declare (a model inventing one) is
+refused alone, never dropped and run on the default route:
```text
Task 0: the delegation backend is 'profile_routes', which does not take 'option' (declared by 'model_map'), so
diff --git a/website/docs/user-guide/features/delegation.md b/website/docs/user-guide/features/delegation.md
index 53e83662b24..8040ba38c30 100644
--- a/website/docs/user-guide/features/delegation.md
+++ b/website/docs/user-guide/features/delegation.md
@@ -331,7 +331,7 @@ The model only ever sees the names and descriptions you configured, never raw pr
**Failures are explicit, never a silent switch.** If the selected backend is missing (plugin not installed or disabled) or reports it cannot run, `delegate_task` returns a tool error naming the backend and the fix, and no subagent starts; it never quietly runs the children on the default route. Within a batch, a task its backend cannot route (an unknown option, a parameter the selected backend does not take, a profile that does not exist, a `service_tier` the route does not offer, an unknown `reasoning_effort`, missing credentials) is refused alone: its result entry has `status: "error"`, the reason, and `route.refused: true`, while the other tasks run. A model route without its own `fallback_providers` uses `delegation.fallback_providers`; `fallback_providers: []` on the route disables fallback for it. A profile route uses that profile's own fallback chain.
-**Switching back.** `/delegation default` (from the `advanced-delegation` plugin) saves `delegation.backend` to `config.yaml`; subagents route on it from the next `delegate_task` call. The per-task parameters the model sees (option or profile names) are part of the cached tool list, so they change from the next session (`/new`). `/delegation <backend> --now` also rebuilds the current session's tool list at its next turn, at the cost of one prompt-cache miss. Until then, a task that sends the previous backend's parameter (an `option` after switching to `profile_routes`) is refused with a message naming the backend, the parameter and the fix (`/delegation <backend> --now`, or `/new`); it never runs on the new backend's default route. Without the plugin, `hermes config set delegation.backend default` restores the default.
+**Switching back.** `/delegation default` (from the `advanced-delegation` plugin) saves `delegation.backend` to `config.yaml` and applies from the next session (`/new`): a running chat keeps routing on the backend it started with, because the per-task choices the model sees (option or profile names) are part of the cached tool list and the two switch together. A hand edit of `delegation.backend` behaves the same. `/delegation <backend> --now` also rebuilds the current chat's tools at its next turn, so it routes on and offers the new backend from there, at the cost of one prompt-cache miss (context compression, which rebuilds the tools anyway, picks up the saved backend too). A task that sends a parameter its chat's backend does not take is refused with a message naming the backend, the parameter and the fix (`/delegation <backend> --now`, or `/new`); it never runs on the backend's default route. Without the plugin, `hermes config set delegation.backend default` restores the default.
:::note Profile routes share credentials
Listing a profile in `delegation.backends.profile_routes` lets this profile's subagents use that profile's credentials, credential pool, `SOUL.md` and terminal policy. Only list profiles whose keys and terminal access you are happy for this profile's agent to use.