Drop subagent task notifications from parent timeline

Subagent task_notification system messages arrive without
parent_tool_use_id but with tool_use_id pointing at the parent's Task
call, so they slip past the sidechain router and render as top-level
"Task Notification" rows in the parent's timeline. Skip them when the
referenced tool_use is a Task call; parent-level background bash
notifications still flow through.
This commit is contained in:
Mohamed Boudra
2026-05-04 10:13:44 +07:00
parent 72e7c7e1ed
commit 78fe3e4df3

View File

@@ -2975,6 +2975,16 @@ class ClaudeAgentSession implements AgentSession {
return; return;
} }
if (message.subtype === "task_notification") { if (message.subtype === "task_notification") {
// TODO: subagent timelines are best-effort. Subagent task_notifications
// arrive without parent_tool_use_id but with tool_use_id pointing at the
// parent's Task call, so they slip past the sidechain router and pollute
// the parent timeline. Drop them here; eventually thread them into the
// parent Task tool call's sub_agent log instead.
const taskUseId = message.tool_use_id;
const cachedTool = taskUseId ? this.toolUseCache.get(taskUseId) : undefined;
if (cachedTool?.name === "Task") {
return;
}
const taskNotificationItem = mapTaskNotificationSystemRecordToToolCall(message); const taskNotificationItem = mapTaskNotificationSystemRecordToToolCall(message);
if (taskNotificationItem) { if (taskNotificationItem) {
events.push({ events.push({