Files
agent-zero/extensions/python/tool_step_description/_10_parallel_step.py
T
linkliti b850a0a094 feat(tools): let bundled tool plugins supply streamed step labels
Per-action streamed labels now cover only the calls whose arguments take real printing time: code execution, text editor, browser evaluate, and call_subordinate with its requested profile. Labels reuse the owning tool classes' verb maps, and the parallel tool names the first of its calls and the remaining count.

Validation: pytest tests/test_plugin_tool_step_descriptions.py (52 passed), tests/test_tool_step_description.py (14 passed), tests/test_plain_response_logging.py (18 passed), tests/test_response_stream_cadence.py (3 passed)
2026-11-28 13:35:54 +03:00

33 lines
1.2 KiB
Python

import json
from helpers.extension import Extension
class ParallelStep(Extension):
def execute(self, ctx: dict | None = None, **kwargs) -> None:
if not isinstance(ctx, dict) or ctx.get("tool_name") != "parallel":
return
args = ctx.get("tool_args")
if not isinstance(args, dict):
return
raw_calls = next((args[key] for key in ("tool_calls", "calls", "items") if key in args), None)
if isinstance(raw_calls, str):
try:
raw_calls = json.loads(raw_calls)
except json.JSONDecodeError:
return
if not isinstance(raw_calls, list) or not raw_calls:
return
head = ""
if isinstance(raw_calls[0], dict):
name = raw_calls[0].get("tool_name") or raw_calls[0].get("tool") or raw_calls[0].get("name")
if isinstance(name, str) and name:
head = name.replace("_", " ")
if not head:
return
more = len(raw_calls) - 1
if more > 0:
ctx["step"] = f"Using in parallel {head} and {more} more tools"
else:
ctx["step"] = f"Using in parallel {head}"