Agent Zero AI framework
fix(delegation): honor names when continuing subordinates
Alessandrof653f6102900
diff --git a/prompts/agent.system.tool.call_sub.md b/prompts/agent.system.tool.call_sub.mdindex 6733785ef..78c75423c 100644--- a/prompts/agent.system.tool.call_sub.md+++ b/prompts/agent.system.tool.call_sub.md@@ -4,7 +4,7 @@ always use specialized subordinate agents for specialized tasks matching their pwhen a request calls for independent perspectives, challenges, or workstreams, delegate them to separate subordinates instead of performing them all with parent toolsargs: `message`, optional `profile`, `name`, `reset`, `context_id`, `attachments`- `profile`: optional prompt profile key for the subordinate; when provided, it must exactly match an available profile; leave empty for the default profile-- `name`: optional label for the child context, shown in listings; defaults to a short task label+- `name`: optional label for the child context, shown in listings; defaults to a short task label for new children; when continuing a child, a non-empty name updates its label- `reset`: use json boolean `true` to create a fresh child; use `false` to continue the default child or the supplied `context_id`- `context_id`: stable child ID returned by an earlier direct or parallel call; use it with `reset: false` to continue that exact child- `attachments`: optional list of file paths/URIs passed to the subordinate's task message so it can read them directlydiff --git a/tests/test_parallel_tool.py b/tests/test_parallel_tool.pyindex efa2ae93f..43d464b1d 100644--- a/tests/test_parallel_tool.py+++ b/tests/test_parallel_tool.py@@ -678,9 +678,12 @@ async def test_failed_parallel_subordinate_continues_directly_or_in_parallel(message="continue after the API failure",context_id=child_id,reset=False,+ name="Direct continuation",)assert direct_result.message == "A1 continuation 2"assert direct_result.additional == {"context_id": child_id}+ child = AgentContext.get(child_id)+ assert child.name == child.get_output_data("parent_context_label") == "Direct continuation"continued = parallel_tools.ParallelJob(id="callsubordin-continued",@@ -691,6 +694,7 @@ async def test_failed_parallel_subordinate_continues_directly_or_in_parallel("message": "continue once more","context_id": child_id,"reset": False,+ "name": "Parallel continuation",},kind="subordinate",parent_agent=parent.agent0,@@ -702,6 +706,7 @@ async def test_failed_parallel_subordinate_continues_directly_or_in_parallel(assert continued.worker_context_id == child_idassert continued.result == "A1 continuation 3"assert calls == {child_id: 3}+ assert child.name == child.get_output_data("parent_context_label") == "Parallel continuation"finally:if child_id:AgentContext.remove(child_id)diff --git a/tests/test_subagent_profiles.py b/tests/test_subagent_profiles.pyindex e9655db23..8e9d17a54 100644--- a/tests/test_subagent_profiles.py+++ b/tests/test_subagent_profiles.py@@ -358,6 +358,7 @@ def test_persisted_numbered_child_is_reusable_after_reload(monkeypatch) -> None:parent.agent0,reset=True,message="persist me",+ name="Original worker",)context_id = child.context.idtry:@@ -378,6 +379,12 @@ def test_persisted_numbered_child_is_reusable_after_reload(monkeypatch) -> None:assert restored.get_output_data("parent_agent_number") == 0assert resumed is restored.agent0assert resumed.get_data(Agent.DATA_NAME_SUPERIOR) is parent.agent0+ assert restored.name == restored.get_output_data("parent_context_label") == "Original worker"+ call_subordinate.get_or_create_subordinate(parent.agent0, context_id=context_id, name="Renamed worker")+ renamed = persist_chat._serialize_context(restored)+ AgentContext.remove(context_id)+ restored = persist_chat._deserialize_context(renamed)+ assert restored.name == restored.get_output_data("parent_context_label") == "Renamed worker"finally:AgentContext.remove(context_id)AgentContext.remove(parent_id)diff --git a/tools/call_subordinate.py b/tools/call_subordinate.pyindex c6a1fcb6b..be40b4d03 100644--- a/tools/call_subordinate.py+++ b/tools/call_subordinate.py@@ -152,6 +152,10 @@ def get_or_create_subordinate(f"Subordinate context '{subordinate.context.id}' is still running. ""Await or cancel its parallel job before continuing it.")+ label = str(name or "").strip()+ if label and subordinate.context is not parent.context:+ subordinate.context.name = label+ subordinate.context.set_output_data(CHILD_PARENT_CONTEXT_LABEL_KEY, label)return subordinateoverride_settings = {"agent_profile": requested_profile} if requested_profile else Nonediff --git a/tools/call_subordinate.py.dox.md b/tools/call_subordinate.py.dox.mdindex 00f8edb21..9eef419d0 100644--- a/tools/call_subordinate.py.dox.md+++ b/tools/call_subordinate.py.dox.md@@ -29,6 +29,7 @@- Observed side-effect areas: filesystem writes, settings/state persistence.- `profile`/`agent_profile` values are validated against available profile keys before use; unknown profiles raise `RepairableException` so the agent can retry with a real profile.- Direct and parallel calls use the same creation, continuation, message, history, and persistence functions in this module.+- A non-empty `name` updates both the child context name and sidebar label on creation or continuation. Omission preserves an existing name; legacy same-context children must not rename the parent chat.- Every fresh child is `Agent(parent.number + 1, ...)` in its own persisted child-chat context, so sibling A1 agents can each create their own A2 descendants without sharing streaming state.- `reset=true` creates a fresh child. `reset=false` continues the caller's default child or the exact child named by `context_id`.- Child context IDs are accepted only when their persisted parent context, parent agent number, and child depth match the caller.