Skip to content

Agent Zero AI framework

fix(chat-naming): preserve subordinate labels

Alessandroefed8c212ceb
diff --git a/plugins/_chat_naming/AGENTS.md b/plugins/_chat_naming/AGENTS.md
index cb13762ae..00778213c 100644
--- a/plugins/_chat_naming/AGENTS.md
+++ b/plugins/_chat_naming/AGENTS.md
@@ -22,6 +22,7 @@
- `always` is the default and considers the latest user message plus recent user context; `once` names only unnamed user chats from their first user message. Preserve explicitly saved modes.
- Generated names are concise and normalized before persistence.
- Renaming a parallel child updates both its context name and sidebar label.
+- Automatic naming skips delegated child contexts; their labels belong to `call_subordinate` or an explicit rename action, in both direct and parallel execution.
- Manual task renames update both scheduler metadata and the task context name.
- `/rename auto` uses the same generation and persistence helpers as the rename modal; any other non-empty argument is saved as the custom chat name.
diff --git a/plugins/_chat_naming/README.md b/plugins/_chat_naming/README.md
index 80b367f58..bae9a2dff 100644
--- a/plugins/_chat_naming/README.md
+++ b/plugins/_chat_naming/README.md
@@ -5,3 +5,5 @@ Chat Naming adds a standard sidebar action for manually renaming chats and tasks
Automatic naming is configured per project and agent profile. By default, it reviews the name after every user message using recent user-only context, changing it when the topic changes. It runs after the response, so its Utility Model call never delays the Main Model. Select **Only once** to name an unnamed chat from its first user message instead. Previously saved settings are preserved; switch existing **Only once** configurations to **After every user message** to enable topic updates.
Use `/rename New Chat Name` to rename the current chat directly, or `/rename auto` to generate and save a name with its configured Utility Model.
+
+Subordinate chats keep their delegation labels. Automatic naming does not overwrite them; an explicit rename action or a new `call_subordinate` name can change them.
diff --git a/plugins/_chat_naming/extensions/python/monologue_end/_60_rename_chat.py b/plugins/_chat_naming/extensions/python/monologue_end/_60_rename_chat.py
index eb9c2ab43..cd3a0dd1c 100644
--- a/plugins/_chat_naming/extensions/python/monologue_end/_60_rename_chat.py
+++ b/plugins/_chat_naming/extensions/python/monologue_end/_60_rename_chat.py
@@ -12,6 +12,8 @@ class RenameChat(Extension):
return
if self.agent.context.type != AgentContextType.USER:
return
+ if self.agent.context.get_output_data("parent_context_id"):
+ return
config = naming.get_config(self.agent)
if not config["automatic_naming"]:
diff --git a/plugins/_chat_naming/tests/test_chat_naming.py b/plugins/_chat_naming/tests/test_chat_naming.py
index bd4afea10..6f164d952 100644
--- a/plugins/_chat_naming/tests/test_chat_naming.py
+++ b/plugins/_chat_naming/tests/test_chat_naming.py
@@ -37,6 +37,8 @@ class _Agent:
type=AgentContextType.USER,
)
self.context.agent0 = self
+ self.context.output_data = {}
+ self.context.get_output_data = self.context.output_data.get
self.history = _History(messages)
self.config = SimpleNamespace(profile="agent0")
self._response = response
@@ -64,6 +66,20 @@ async def test_user_message_selection_excludes_assistant_work_and_tool_results()
assert naming.latest_user_sequence(agent) == 4
[email protected]("mode", ["once", "always"])
+async def test_automatic_naming_preserves_delegated_labels(monkeypatch, mode):
+ agent = _Agent([_Message({"user_message": "Investigate the issue"})], name="A1-summoner")
+ agent.context.output_data.update(parent_context_id="parent", parent_context_label="A1-summoner")
+ monkeypatch.setattr(naming, "get_config", lambda _agent: {
+ "automatic_naming": True, "automatic_naming_mode": mode,
+ })
+ scheduled = []
+ monkeypatch.setattr(rename_chat.asyncio, "create_task", scheduled.append)
+ await rename_chat.RenameChat(agent=agent).execute()
+ assert not scheduled
+ assert agent.context.name == agent.context.output_data["parent_context_label"] == "A1-summoner"
+
+
async def test_once_mode_uses_first_message_and_does_not_override_a_name(monkeypatch):
scheduled = []
agent = _Agent(