Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions apps/sim/lib/slack-search/assistant-stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ describe('Slack tool progress', () => {
expect(api.start).toHaveBeenCalledOnce()
})

it('reports failed tools without exposing arguments, account labels, or backend errors', async () => {
it('completes recovered tool failures without exposing arguments, account labels, or backend errors', async () => {
const { stream } = setup()
await stream.start()
const call = toolCall()
Expand All @@ -372,8 +372,21 @@ describe('Slack tool progress', () => {
output: { accountLabel: 'private account' },
},
})
await stream.onEvent(toolCall('search_workspace', 'tool-2'))
await stream.onEvent(toolResult('search_workspace', 'tool-2'))
await stream.onEvent({ type: 'text', payload: { channel: 'assistant', text: 'Answer.' } })
await stream.finish(result)
const chunks = deliveredChunks()
expect(chunks[1]).toEqual({ ...chunks[0], status: 'error' })
const tasks = chunks.filter((chunk) => chunk.type === 'task_update')
expect(tasks.map((chunk) => chunk.status)).toEqual([
'in_progress',
'complete',
'in_progress',
'complete',
])
expect(deliveredText()).toBe('Answer.')
expect(api.stop.mock.calls[0][5]).toEqual([])
expect(api.stop.mock.calls[0][6]).toEqual([])
Comment thread
TheodoreSpeaks marked this conversation as resolved.
expect(JSON.stringify(chunks)).not.toContain('private')
})

Expand Down
12 changes: 5 additions & 7 deletions apps/sim/lib/slack-search/assistant-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,11 @@ export class SlackSearchAssistantStream {
if (!existing || existing.chunk.status !== 'in_progress') return
if (existing.toolName !== payload.toolName)
throw new Error('Slack tool progress identity changed')
chunk = {
...existing.chunk,
status:
payload.success && (!payload.status || payload.status === 'success')
? 'complete'
: 'error',
}
/**
* The agent recovers from individual tool failures, and Slack collapses a timeline with any
* errored task under "Something went wrong"; only an interrupted answer reports an error.
*/
chunk = { ...existing.chunk, status: 'complete' }
}
this.toolProgress.set(payload.toolCallId, { toolName: payload.toolName, chunk })
/** Existing task updates can be delivered without waiting for preceding answer text. */
Expand Down
Loading