Skip to content

The agent that grows with you

fix: managed worker outbox directory is a portable spelling of the execution id

Teknium4a08032d3568
diff --git a/agent/managed_worker.py b/agent/managed_worker.py
index 8c1ca7aabf0..25b530af7ef 100644
--- a/agent/managed_worker.py
+++ b/agent/managed_worker.py
@@ -149,6 +149,12 @@ class WorkerControls:
self.channel.send('prompt_settled', prompt_id=prompt_id)
+def outbox_dir(home, execution_id):
+ """execution_id is a ledger key ('admission-worker:<hex>'); ':' is not a legal Windows path
+ character, so the private outbox directory is a portable spelling of the same identity."""
+ return Path(home) / 'worker-outboxes' / execution_id.replace(':', '-')
+
+
def execute(frame, channel):
# The owner RPC below imports gateway/config modules (hermes_cli.config, providers,
# hermes_cli.plugins) transitively; the policy must already be frozen when they load.
@@ -159,7 +165,7 @@ def execute(frame, channel):
adopted = rpc('worker.adopt', **{k: v for k, v in scope.items() if k != 'epoch'})
if adopted['owner_epoch'] != scope['epoch']:
raise RuntimeError('stale_epoch')
- store = RuntimeSessionStore(rpc, scope, Path(frame['home']) / 'worker-outboxes' / scope['execution_id'])
+ store = RuntimeSessionStore(rpc, scope, outbox_dir(frame['home'], scope['execution_id']))
# Store construction binds the delegation ledger before tool discovery.
from gateway.session_policy import restore_policy, policy_scope
policy = restore_policy(frame['policy'])
diff --git a/tests/gateway/test_managed_worker_bypass.py b/tests/gateway/test_managed_worker_bypass.py
index 9da4b84b791..ef7c299f8d1 100644
--- a/tests/gateway/test_managed_worker_bypass.py
+++ b/tests/gateway/test_managed_worker_bypass.py
@@ -99,3 +99,15 @@ print(json.dumps({{'max_turns': cfg['agent']['max_turns'], 'raw_model': raw['mod
assert receipt['plugins'] == [] and receipt['executed'] is False, receipt
else:
assert receipt['executed'] is True, receipt # config-only keeps plugins
+
+
+def test_worker_outbox_directory_is_portable_and_distinct_per_execution(tmp_path):
+ """execution_id ('admission-worker:<hex>') is a durable ledger key, not a path: ':' is
+ illegal in a Windows directory name (WinError 267), so the outbox dir must be derived."""
+ from agent.managed_worker import outbox_dir
+ first = outbox_dir(tmp_path, 'admission-worker:ef7caea811d14c7092fd261cd167b311')
+ second = outbox_dir(tmp_path, 'admission-worker:ef7caea811d14c7092fd261cd167b312')
+ assert first.parent == tmp_path / 'worker-outboxes' and first != second
+ assert not set(first.name).intersection(':\\/<>"|?*'), first.name
+ first.mkdir(parents=True)
+ assert first.is_dir()