Skip to content

Commit f1c093f

Browse files
committed
improvement(chat): keep activity summaries concise
1 parent b970af9 commit f1c093f

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/agent-group/tool-activity-group.test.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ function tool(toolName: string, status: ToolCallStatus = 'success'): ToolCallDat
1010
}
1111

1212
describe('getToolActivitySummary', () => {
13-
it('summarizes distinct actions in the order they occurred', () => {
13+
it('caps distinct actions in order and counts the remaining categories, not repeated calls', () => {
1414
expect(
1515
getToolActivitySummary([tool('read'), tool('terminal_run'), tool('read'), tool('grep')])
16-
).toBe('Read files, ran commands, searched files')
16+
).toBe('Read files, ran commands +1 more')
1717
})
1818

1919
it('summarizes browser navigation and interactions without repeating actions', () => {
@@ -24,7 +24,7 @@ describe('getToolActivitySummary', () => {
2424
tool('browser_type'),
2525
tool('browser_navigate'),
2626
])
27-
).toBe('Navigated pages, read pages, entered text')
27+
).toBe('Navigated pages, read pages +1 more')
2828
})
2929

3030
it('does not describe unsuccessful work as completed actions', () => {
@@ -79,9 +79,21 @@ describe('getToolActivitySummary', () => {
7979
tool('deploy_as_api'),
8080
tool('table_rows'),
8181
])
82-
).toBe(
83-
'Navigated pages, filled forms, entered text, read documents, ran workflows, deployed workflows, used tables'
84-
)
82+
).toBe('Navigated pages, filled forms +5 more')
83+
})
84+
85+
it('keeps failure and interruption counts visible when action categories are capped', () => {
86+
expect(
87+
getToolActivitySummary([
88+
tool('read'),
89+
tool('grep'),
90+
tool('terminal'),
91+
tool('browser_navigate'),
92+
tool('apply_file_edit', 'error'),
93+
tool('wait', 'interrupted'),
94+
tool('browser_type', 'skipped'),
95+
])
96+
).toBe('Read files, searched files +2 more · 1 failed · 1 stopped · 1 skipped')
8597
})
8698

8799
it('describes terminal runs from their operation', () => {

apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/agent-group/tool-activity-group.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import type { ToolCallItemProps } from '@/app/workspace/[workspaceId]/home/compo
88
import { getToolIcon } from '@/app/workspace/[workspaceId]/home/components/message-content/utils'
99
import { type ToolCallData, ToolCallStatus } from '@/app/workspace/[workspaceId]/home/types'
1010

11+
const MAX_SUMMARY_ACTIONS = 2
12+
1113
const ACTIVITY_LABELS: Readonly<Record<string, string>> = {
1214
read: 'read files',
1315
read_document: 'read documents',
@@ -80,14 +82,16 @@ export function getToolActivitySummary(tools: ToolCallData[]): string {
8082
else if (tool.status === ToolCallStatus.skipped || tool.status === ToolCallStatus.rejected)
8183
skipped++
8284
}
83-
const summary = Array.from(labels).join(', ')
85+
const summary = Array.from(labels).slice(0, MAX_SUMMARY_ACTIONS).join(', ')
86+
const summaryLabel = summary ? summary[0].toUpperCase() + summary.slice(1) : 'Tool activity'
87+
const additionalActions = Math.max(0, labels.size - MAX_SUMMARY_ACTIONS)
8488
const outcomes = [
8589
failed && `${failed} failed`,
8690
stopped && `${stopped} stopped`,
8791
skipped && `${skipped} skipped`,
8892
].filter(Boolean)
8993
return [
90-
summary ? summary[0].toUpperCase() + summary.slice(1) : 'Tool activity',
94+
additionalActions > 0 ? `${summaryLabel} +${additionalActions} more` : summaryLabel,
9195
...outcomes,
9296
].join(' · ')
9397
}

0 commit comments

Comments
 (0)