Skip to content

The agent that grows with you

feat: project managed tool progress without private arguments or results

Teknium61ccd894c367
diff --git a/agent/managed_worker.py b/agent/managed_worker.py
index 734fc45692b..0b0f77ceec6 100644
--- a/agent/managed_worker.py
+++ b/agent/managed_worker.py
@@ -162,7 +162,9 @@ def execute(frame, channel):
skip_context_files=policy.ignore_rules, load_soul_identity=not policy.ignore_rules,
skip_memory=policy.ignore_rules, skip_background_review=True, quiet_mode=True,
stream_delta_callback=lambda text: channel.send('delta', text=text) if text else None,
- clarify_callback=controls.clarify)
+ clarify_callback=controls.clarify,
+ tool_start_callback=lambda call_id, name, args: channel.send('tool.start', tool_call_id=call_id, name=name),
+ tool_complete_callback=lambda call_id, name, args, result: channel.send('tool.complete', tool_call_id=call_id, name=name))
controls.agent = agent
if controls.stopped.is_set():
agent.interrupt()
diff --git a/gateway/session_managed_worker.py b/gateway/session_managed_worker.py
index 260710a4602..2ffd4f8bfcc 100644
--- a/gateway/session_managed_worker.py
+++ b/gateway/session_managed_worker.py
@@ -177,6 +177,11 @@ async def execute_managed(authority, ref, row, policy):
if kind == 'delta' and set(frame) == {'type', 'text'} and isinstance(frame['text'], str):
authority.publish_execution(ref.session_id, row['generation'], 'message.delta', {'text': frame['text']})
continue
+ if (kind in {'tool.start', 'tool.complete'} and set(frame) == {'type', 'tool_call_id', 'name'}
+ and isinstance(frame['tool_call_id'], str) and isinstance(frame['name'], str)):
+ authority.publish_execution(ref.session_id, row['generation'], kind,
+ {'tool_call_id': frame['tool_call_id'], 'name': frame['name']})
+ continue
if kind == 'result' and set(frame) == {'type', 'result'} and accepted is None:
result = frame['result']
if (not isinstance(result, dict) or set(result) - {'final_response', 'failed', 'interrupted'}
diff --git a/tests/gateway/test_managed_worker_launch.py b/tests/gateway/test_managed_worker_launch.py
index f28cf7878b2..2fce805b59f 100644
--- a/tests/gateway/test_managed_worker_launch.py
+++ b/tests/gateway/test_managed_worker_launch.py
@@ -161,6 +161,11 @@ def test_ordinary_owner_launches_tool_worker_and_detach_does_not_cancel(tmp_path
restored = await rpc(ws, 'session.resume', session_id=sid)
history = restored['result']['messages']
assert 'MANAGED_TOOL_DONE' in json.dumps(history), restored
+ replay = await rpc(ws, 'session.events.since', session_id=sid,
+ replay_epoch=restored['result']['replay_epoch'], last_sequence=0)
+ tools = [e for e in replay['result']['events'] if e['type'] in {'tool.start', 'tool.complete'}]
+ assert tools and tools[0]['type'] == 'tool.start' and tools[-1]['type'] == 'tool.complete', replay
+ assert str(target) not in json.dumps(tools) and 'MANAGED_TOOL_EFFECT' not in json.dumps(tools), tools
rows = query('SELECT role,content FROM messages WHERE session_id=? ORDER BY id', (sid,))
assert sum(role == 'user' and 'DO_MANAGED_TOOL' in content for role, content in rows) == 1, rows
assert sum(role == 'assistant' and 'MANAGED_TOOL_DONE' in (content or '') for role, content in rows) == 1, rows