test: add disallowedTools blocking custom tool test

This commit is contained in:
JackChen 2026-04-15 15:10:02 +08:00
parent 38a88df144
commit 9b487ca368
1 changed files with 24 additions and 0 deletions

View File

@ -205,6 +205,30 @@ describe('OpenMultiAgent', () => {
expect(toolNames).not.toContain('bash')
})
it('customTools can be blocked by disallowedTools', async () => {
mockAdapterResponses = ['done']
const { z } = await import('zod')
const { defineTool } = await import('../src/tool/framework.js')
const myTool = defineTool({
name: 'my_custom_tool',
description: 'A custom tool for testing',
inputSchema: z.object({ query: z.string() }),
execute: async ({ query }) => ({ data: query }),
})
const oma = new OpenMultiAgent({ defaultModel: 'mock-model' })
await oma.runAgent(
{ ...agentConfig('solo'), customTools: [myTool], disallowedTools: ['my_custom_tool'] },
'test',
)
const toolNames = capturedChatOptions[0]?.tools?.map(t => t.name) ?? []
expect(toolNames).not.toContain('my_custom_tool')
})
it('fires onProgress events', async () => {
mockAdapterResponses = ['done']