Skip to content

Commit 7a36d74

Browse files
fix(slack-search): stop recovered tool failures from flagging the whole reply (#8336)
1 parent d9b9e1d commit 7a36d74

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

‎apps/sim/lib/slack-search/assistant-stream.test.ts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ describe('Slack tool progress', () => {
355355
expect(api.start).toHaveBeenCalledOnce()
356356
})
357357

358-
it('reports failed tools without exposing arguments, account labels, or backend errors', async () => {
358+
it('completes recovered tool failures without exposing arguments, account labels, or backend errors', async () => {
359359
const { stream } = setup()
360360
await stream.start()
361361
const call = toolCall()
@@ -372,8 +372,21 @@ describe('Slack tool progress', () => {
372372
output: { accountLabel: 'private account' },
373373
},
374374
})
375+
await stream.onEvent(toolCall('search_workspace', 'tool-2'))
376+
await stream.onEvent(toolResult('search_workspace', 'tool-2'))
377+
await stream.onEvent({ type: 'text', payload: { channel: 'assistant', text: 'Answer.' } })
378+
await stream.finish(result)
375379
const chunks = deliveredChunks()
376-
expect(chunks[1]).toEqual({ ...chunks[0], status: 'error' })
380+
const tasks = chunks.filter((chunk) => chunk.type === 'task_update')
381+
expect(tasks.map((chunk) => chunk.status)).toEqual([
382+
'in_progress',
383+
'complete',
384+
'in_progress',
385+
'complete',
386+
])
387+
expect(deliveredText()).toBe('Answer.')
388+
expect(api.stop.mock.calls[0][5]).toEqual([])
389+
expect(api.stop.mock.calls[0][6]).toEqual([])
377390
expect(JSON.stringify(chunks)).not.toContain('private')
378391
})
379392

‎apps/sim/lib/slack-search/assistant-stream.ts‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,11 @@ export class SlackSearchAssistantStream {
237237
if (!existing || existing.chunk.status !== 'in_progress') return
238238
if (existing.toolName !== payload.toolName)
239239
throw new Error('Slack tool progress identity changed')
240-
chunk = {
241-
...existing.chunk,
242-
status:
243-
payload.success && (!payload.status || payload.status === 'success')
244-
? 'complete'
245-
: 'error',
246-
}
240+
/**
241+
* The agent recovers from individual tool failures, and Slack collapses a timeline with any
242+
* errored task under "Something went wrong"; only an interrupted answer reports an error.
243+
*/
244+
chunk = { ...existing.chunk, status: 'complete' }
247245
}
248246
this.toolProgress.set(payload.toolCallId, { toolName: payload.toolName, chunk })
249247
/** Existing task updates can be delivered without waiting for preceding answer text. */

0 commit comments

Comments
 (0)