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 <noreply@anthropic.com>

* fix: keep agent read labels in shared session transcripts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
This commit is contained in:
Guilhem
2026-11-10 15:46:46 +01:00
committed by GitHub
co-authored by Claude Opus 5.5 Ruben Fiszel
parent abfa6b1a67
commit 80e2be56dd
5 changed files with 28 additions and 4 deletions
@@ -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
})
@@ -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
@@ -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'),
@@ -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`
@@ -140,6 +140,7 @@ function readMessage(m: Record<string, unknown>, 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),