From 80e2be56ddd21cd7f5ea778989e83e09e87b08f5 Mon Sep 17 00:00:00 2001 From: Guilhem Date: Tue, 10 Nov 2026 15:46:46 +0100 Subject: [PATCH] fix: name agents in session chat tool call labels (#12313) * fix: name agents in session chat tool call labels Co-Authored-By: Claude Opus 5.5 * fix: keep agent read labels in shared session transcripts Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 Co-authored-by: Ruben Fiszel --- .../lib/components/copilot/chat/global/core.ts | 15 +++++++++++---- .../src/lib/components/copilot/chat/shared.ts | 2 ++ .../components/copilot/chat/toolGroups.test.ts | 12 ++++++++++++ .../src/lib/components/copilot/chat/toolGroups.ts | 2 ++ .../src/lib/components/sessions/sessionSharing.ts | 1 + 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/copilot/chat/global/core.ts b/frontend/src/lib/components/copilot/chat/global/core.ts index 504447195a..a02c7acc1e 100644 --- a/frontend/src/lib/components/copilot/chat/global/core.ts +++ b/frontend/src/lib/components/copilot/chat/global/core.ts @@ -3553,10 +3553,13 @@ export const globalTools: SessionTool<{}>[] = [ } else if (read.success === false) { toolCallbacks.setToolStatus(toolId, { content: read.error, error: read.error }) } else { + const readsAgent = read.value?.resource_type === 'ai_agent' + const noun = readsAgent ? 'agent' : type toolCallbacks.setToolStatus(toolId, { content: read.isDraft - ? `Read draft ${type} "${parsed.path}"` - : `Read ${type} "${parsed.path}"` + ? `Read draft ${noun} "${parsed.path}"` + : `Read ${noun} "${parsed.path}"`, + readsAgent }) } return text @@ -7009,8 +7012,12 @@ async function deployDraft( throw new Error(`Draft ${type} "${path}" has no value to deploy.`) } + const noun = + type === 'resource' && (draft.value as CreateResource).resource_type === 'ai_agent' + ? 'agent' + : type toolCallbacks.setToolStatus(toolId, { - content: `Deploying ${type} "${path}"...` + content: `Deploying ${noun} "${path}"...` }) let actions: ToolDisplayAction[] | undefined @@ -7361,7 +7368,7 @@ async function deployDraft( } toolCallbacks.setToolStatus(toolId, { - content: `Deployed ${type} "${path}"`, + content: `Deployed ${noun} "${path}"`, result: 'Deployed', actions }) diff --git a/frontend/src/lib/components/copilot/chat/shared.ts b/frontend/src/lib/components/copilot/chat/shared.ts index 0e9fd516a6..648a8f2353 100644 --- a/frontend/src/lib/components/copilot/chat/shared.ts +++ b/frontend/src/lib/components/copilot/chat/shared.ts @@ -704,6 +704,8 @@ export type ToolDisplayMessage = { autoCollapseDetails?: boolean isStreamingArguments?: boolean toolName?: string + /** A `read_workspace_item` call that found an agent: the tool's `type` only says resource. */ + readsAgent?: boolean /** What marks this row with its provider. Recorded rather than looked up, because the * server listing lives only in memory and a reloaded transcript does not have it. The * workspace rides along: a chat is readable from any workspace, and the same path names diff --git a/frontend/src/lib/components/copilot/chat/toolGroups.test.ts b/frontend/src/lib/components/copilot/chat/toolGroups.test.ts index 2cf5da7095..2b11286830 100644 --- a/frontend/src/lib/components/copilot/chat/toolGroups.test.ts +++ b/frontend/src/lib/components/copilot/chat/toolGroups.test.ts @@ -290,6 +290,18 @@ describe('groupToolRuns', () => { expect(header([mcp('list_issues'), other])).toBe('List issues, get issue') }) + it('counts agent reads apart from other workspace item reads', () => { + const read = { type: 'resource', path: 'f/a/x' } + const agent = { readsAgent: true } + expect( + header([ + tool('read_workspace_item', read, agent), + tool('read_workspace_item', read, agent), + tool('read_workspace_item', read) + ]) + ).toBe('Read 2 agents, read workspace item') + }) + it('names the first three kinds of call and leaves the rest to `more`', () => { const group = groupToolRuns([ tool('search_workspace'), diff --git a/frontend/src/lib/components/copilot/chat/toolGroups.ts b/frontend/src/lib/components/copilot/chat/toolGroups.ts index 99773e6465..5d3f582a6c 100644 --- a/frontend/src/lib/components/copilot/chat/toolGroups.ts +++ b/frontend/src/lib/components/copilot/chat/toolGroups.ts @@ -348,6 +348,7 @@ function mcpServerPath(call: ToolDisplayMessage): string | undefined { } function callName(call: ToolDisplayMessage): string { + if (call.readsAgent) return 'read agent' const mcpTool = call.parameters?.tool const name = call.toolName === 'call_mcp_read_tool' && typeof mcpTool === 'string' @@ -375,6 +376,7 @@ const COUNTED_VERBS = new Set(['read', 'inspect']) function repeated(name: string, n: number): string { if (n === 1) return name const [verb, ...rest] = name.split(' ') + if (name === 'read agent') return `read ${n} agents` return COUNTED_VERBS.has(verb) && rest.length > 0 ? `${verb} ${n} ${rest.join(' ')}` : `${name} ${n} times` diff --git a/frontend/src/lib/components/sessions/sessionSharing.ts b/frontend/src/lib/components/sessions/sessionSharing.ts index 3ecbe214e9..42bb9f2fe7 100644 --- a/frontend/src/lib/components/sessions/sessionSharing.ts +++ b/frontend/src/lib/components/sessions/sessionSharing.ts @@ -140,6 +140,7 @@ function readMessage(m: Record, index: number): DisplayMessage tool_call_id: str(m.tool_call_id) ?? `shared-${index}`, content, toolName: str(m.toolName), + readsAgent: m.readsAgent === true, parameters: m.parameters, result: m.result, logs: str(m.logs),