Agent Zero AI framework
Render parallel code execution as EXE
Alessandro9bb3cb9469c7
diff --git a/helpers/parallel_tools.py b/helpers/parallel_tools.pyindex e9d830bef..5b62bdc5b 100644--- a/helpers/parallel_tools.py+++ b/helpers/parallel_tools.py@@ -600,6 +600,19 @@ def _log_parallel_child_started(agent: "Agent", job: ParallelJob) -> None:)return+ if job.tool_name == "code_execution_tool":+ runtime = job.tool_args.get("runtime", "unknown")+ session = job.tool_args.get("session", None)+ session_text = f"[{session}] " if session or session == 0 else ""+ job.log_item = agent.context.log.log(+ type="code_exe",+ heading=f"icon://terminal {session_text}code_execution_tool - {runtime}",+ content="",+ kvps=job.tool_args,+ id=job.log_id,+ )+ return+heading = f"icon://construction {agent.agent_name}: Using tool '{job.tool_name}'"job.log_item = agent.context.log.log(type="tool",diff --git a/helpers/parallel_tools.py.dox.md b/helpers/parallel_tools.py.dox.mdindex 39e65c4cc..2aedf01ab 100644--- a/helpers/parallel_tools.py.dox.md+++ b/helpers/parallel_tools.py.dox.md@@ -31,6 +31,7 @@- Direct tool background context cleanup removes both the in-memory context and any transient chat folder left on disk.- Parent-visible child log items are created for each wrapped call so the WebUI can inspect concurrent children separately while the wrapper result remains model-history-only.- Child tool logs mirror normal tool-call visible args; job ids remain available through wrapper results and prompt extras rather than visible process-step args.+- Wrapped `code_execution_tool` child logs use the normal `code_exe` WebUI message type and terminal heading so they render like direct code execution calls.- Job IDs are stable handles for later await, collect, or cancel operations.- Prompt extras must stay bounded and expose only job IDs, tool names, status, and compact result/error summaries.diff --git a/tests/test_parallel_tool.py b/tests/test_parallel_tool.pyindex 587604aa8..bfb65e66e 100644--- a/tests/test_parallel_tool.py+++ b/tests/test_parallel_tool.py@@ -427,6 +427,52 @@ async def test_parallel_direct_tool_jobs_log_normal_tool_metadata(monkeypatch) -assert agent.context.log.items[0].kvps == {"seconds": 1, "_tool_name": "wait"}+async def test_parallel_code_execution_child_uses_code_exe_log_type(monkeypatch) -> None:+ class FakeDeferredTask:+ def __init__(self, thread_name=None) -> None:+ self.thread_name = thread_name++ def start_task(self, func, *args):+ return self++ def is_ready(self):+ return False++ def is_alive(self):+ return True++ def kill(self):+ pass++ monkeypatch.setattr(parallel_tools, "DeferredTask", FakeDeferredTask)+ agent = _FakeAgent()++ jobs = await parallel_tools.start_parallel_jobs(+ agent, # type: ignore[arg-type]+ [+ parallel_tools.NormalizedToolCall(+ index=0,+ tool_name="code_execution_tool",+ tool_args={+ "runtime": "terminal",+ "session": 0,+ "code": "pwd",+ },+ )+ ],+ )++ assert jobs[0].kind == "tool"+ assert agent.context.log.items[0].type == "code_exe"+ assert agent.context.log.items[0].heading == "icon://terminal [0] code_execution_tool - terminal"+ assert agent.context.log.items[0].kvps == {+ "runtime": "terminal",+ "session": 0,+ "code": "pwd",+ }++@pytest.mark.asyncioasync def test_parallel_tool_keeps_wrapper_out_of_visible_log() -> None:from tools.parallel import ParallelTool