fix: show tool parameters and skip duplicate calls

This commit is contained in:
2026-09-27 14:47:55 +08:00
parent 40fd07a1bc
commit e5bf1cf250
7 changed files with 192 additions and 42 deletions
+14 -3
View File
@@ -8,10 +8,14 @@ async function mockApi(page: Page) {
content: '# 标题\n\n段落 [安全链接](https://example.com) [危险链接](javascript:alert(1)) <img src=x onerror=alert(1)>\n\n> 引用\n\n- 列表\n\n| A | B |\n|---|---|\n| 1 | 2 |\n\n```js\nconst x = 1;\n```',
citations: [{ title: '资料.pdf', page: 2, quote: '原文摘录', url: '/api/pages/2' }, { title: '资料.pdf', page: 2, quote: '原文摘录', url: '/api/pages/2' },
{ chunk_id: 2977, title: '综合报告.pdf', page: 48, quote: '第48页原文片段', url: '/api/pages/48' }],
tool_calls: [{ id: 'call-one', name: 'search_project_material', status: 'completed', arguments: { project_id: 1 },
tool_calls: [{ id: 'call-one', name: 'search_project_material', status: 'completed', arguments: { project_id: 1, omitted_text_fields: 1 },
summary: '找到 1 条引用', result: { found: true, citations: [{ page: 48, quote: '第48页原文片段' }] } },
{ id: 'call-two', name: 'get_scores', status: 'completed', arguments: { batch_id: 3, criterion_offset: 0 },
summary: '返回 1 项评分', result: { next_criterion_offset: 6, results: [{ rows: [{ criterion_id: 'C1', final_score: 8 }] }] } }] }],
{ id: 'call-two', name: 'get_scores', status: 'completed', arguments: { batch_id: 3, omitted_text_fields: 1 },
summary: '返回 1 项评分', result: { project_offset: 0, criterion_offset: 6, next_criterion_offset: 12, results: [{ rows: [{ criterion_id: 'C1', final_score: 8 }] }] } },
{ id: 'call-three', name: 'search_project_material', status: 'completed', arguments: { project_id: 1, query: '视觉检测' },
summary: '找到 1 条引用', result: { found: true, citations: [] } },
{ id: 'call-four', name: 'search_project_material', status: 'skipped', arguments: { project_id: 1, query: '视觉检测' },
summary: '重复调用已跳过', result: { previous_call_id: 'call-three' } }] }],
actions: [], runs: [{ id: 1, status: 'completed', tool_calls: [] }] },
};
let nextId = 8;
@@ -103,6 +107,13 @@ test('markdown, citations, tool folding and narrow layout are safe', async ({ pa
await expect(page.locator('.tool-detail').first()).toContainText('第48页原文片段');
await page.locator('.chat-tool').nth(1).locator('summary').click();
await expect(page.locator('.chat-tool').nth(1).locator('.tool-detail')).toContainText('C1');
await expect(page.locator('.chat-tool').nth(1).locator('.tool-detail')).toContainText('评分项偏移量');
await expect(page.locator('.chat-tool').nth(1).locator('.tool-detail')).toContainText('6');
await expect(page.locator('.chat-tool').first().locator('.tool-detail')).toContainText('历史调用未保存查询词');
await page.locator('.chat-tool').nth(2).locator('summary').click();
await expect(page.locator('.chat-tool').nth(2).locator('.tool-detail')).toContainText('查询词 (query)');
await expect(page.locator('.chat-tool').nth(2).locator('.tool-detail')).toContainText('视觉检测');
await expect(page.locator('.chat-tool').nth(3).locator('summary')).toContainText('已跳过');
await page.locator('.chat-citation-group > summary').click();
await expect(page.locator('.chat-citation-group')).toHaveAttribute('open', '');
await expect(page.getByText('资料.pdf')).toBeVisible();