Skip to content

The agent that grows with you

fix(delegation): managed workers accept the tool pin's delegation_backend

Teknium1bc291ab3049
diff --git a/agent/runtime_session_store.py b/agent/runtime_session_store.py
index 3393da5fce7..f05c66459eb 100644
--- a/agent/runtime_session_store.py
+++ b/agent/runtime_session_store.py
@@ -481,8 +481,8 @@ class RuntimeSessionStore(RuntimeSessionCompressionMixin, RuntimeSessionLifecycl
self._apply('session.sidecars', {'patch': patch})
def update_session_tool_names(self, session_id, pin):
- # The tools[] freeze pin ({"version", "tools"}; None clears): without it every fresh worker
- # re-probes check_fns and a config flip between turns silently forks the cached prefix.
+ # The tools[] freeze pin ({"version", "tools"[, "delegation_backend"]}; None clears): without it every
+ # fresh worker re-probes check_fns and a config flip between turns silently forks the cached prefix.
self._session(session_id)
self._apply('session.tools', {'tool_names': pin})
diff --git a/hermes_state_worker_context.py b/hermes_state_worker_context.py
index b132aa4137e..e59b9dd2233 100644
--- a/hermes_state_worker_context.py
+++ b/hermes_state_worker_context.py
@@ -46,7 +46,7 @@ def worker_sidecars(db, conn, session_id, payload):
def worker_tool_names(db, conn, session_id, payload):
"""The tools[] pin, same contract as ``SessionDB.update_session_tool_names``: any JSON pin
- (``{"version", "tools"}`` today; a legacy name list) content-addressed through ``system_prompts``,
+ (``{"version", "tools"[, "delegation_backend"]}`` today; a legacy name list) content-addressed through ``system_prompts``,
``None`` clears. Bounded so a worker cannot write an unbounded blob into the shared table."""
if set(payload) != {'tool_names'}:
raise RuntimeStoreError('invalid_params')
@@ -56,8 +56,11 @@ def worker_tool_names(db, conn, session_id, payload):
raise RuntimeStoreError('invalid_params')
if isinstance(pin, list) and not all(isinstance(n, str) and 0 < len(n) <= 256 for n in pin):
raise RuntimeStoreError('invalid_params')
- if isinstance(pin, dict) and (set(pin) != {'version', 'tools'} or not isinstance(pin['version'], str)
- or not isinstance(pin['tools'], list)):
+ # ``delegation_backend``: the backend the pinned delegate_task was built from (agent/delegation_backends.py).
+ backend = pin.get('delegation_backend', '') if isinstance(pin, dict) else ''
+ if isinstance(pin, dict) and (not {'version', 'tools'} <= set(pin) <= {'version', 'tools', 'delegation_backend'}
+ or not isinstance(pin['version'], str) or not isinstance(pin['tools'], list)
+ or not isinstance(backend, str) or len(backend) > 64):
raise RuntimeStoreError('invalid_params')
encoded = None if pin is None else json.dumps(pin)
if encoded is not None and len(encoded) > 4 * 1024 * 1024: