fix(agent): throw error on read_skill failure instead of returning error content

This commit is contained in:
yiling
2026-07-22 10:43:14 +08:00
parent 9158598c5b
commit bbe1e7128d
2 changed files with 43 additions and 82 deletions
+7 -17
View File
@@ -18,16 +18,11 @@ describe('readSkillTool', () => {
vi.clearAllMocks()
})
it('should return error if skill not found', async () => {
it('should throw error if skill not found', async () => {
const readSkillTool = createReadSkillTool(undefined, () => {})
const result = await readSkillTool.execute(
'1',
{ skillId: 'non-existent' },
undefined,
undefined,
)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((result.content[0] as any).text).toContain('not found')
await expect(
readSkillTool.execute('1', { skillId: 'non-existent' }, undefined, undefined),
).rejects.toThrow('not found')
})
it('should read skill from cache if hash matches', async () => {
@@ -308,14 +303,9 @@ describe('readSkillTool', () => {
expect((resultOwner.content[0] as any).text).toBe('# Owner Skill')
const reviewerTool = createReadSkillTool(reviewerUser.id, () => {})
const resultReviewer = await reviewerTool.execute(
'1',
{ skillId: ownerSkill.id },
undefined,
undefined,
)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((resultReviewer.content[0] as any).text).toContain('Permission denied')
await expect(
reviewerTool.execute('1', { skillId: ownerSkill.id }, undefined, undefined),
).rejects.toThrow('Permission denied')
})
})
})