/ src / lib / chat / tool-event-summary.test.ts
tool-event-summary.test.ts
 1  import { describe, it } from 'node:test'
 2  import assert from 'node:assert/strict'
 3  
 4  import { buildToolEventAssistantSummary } from './tool-event-summary'
 5  
 6  describe('buildToolEventAssistantSummary', () => {
 7    it('summarizes completed tool-only runs', () => {
 8      const summary = buildToolEventAssistantSummary([
 9        { name: 'browser', input: '{"action":"screenshot"}', output: '/api/uploads/wiki.png' },
10        { name: 'send_file', input: '{"filePath":"wiki.png"}', output: '[wiki](/api/uploads/wiki.png)' },
11      ])
12  
13      assert.equal(
14        summary,
15        'Used 2 tool calls (`browser`, `send_file`). See tool output above for details.',
16      )
17    })
18  
19    it('summarizes interrupted in-flight tool runs', () => {
20      const summary = buildToolEventAssistantSummary(
21        [{ name: 'browser', input: '{"action":"navigate"}' }],
22        { interrupted: true },
23      )
24  
25      assert.equal(
26        summary,
27        'Started 1 tool call (`browser`). Progress was interrupted before completion.',
28      )
29    })
30  })