|
1 | 1 | import { TEST_AGENT_RUNTIME_IMPL } from '@codebuff/common/testing/impl/agent-runtime' |
2 | 2 | import { describe, test, expect, mock } from 'bun:test' |
| 3 | +import { convertJsonSchemaToZod } from 'zod-from-json-schema' |
3 | 4 | import { z } from 'zod/v4' |
4 | 5 |
|
5 | 6 | import { buildAgentToolInputSchema, buildAgentToolSet } from '../templates/prompts' |
@@ -172,6 +173,30 @@ describe('Schema handling error recovery', () => { |
172 | 173 | expect(description).toContain('content') |
173 | 174 | }) |
174 | 175 |
|
| 176 | + test('buildToolDescription preserves MCP params when schema is represented as allOf', () => { |
| 177 | + const mcpSchema = convertJsonSchemaToZod({ |
| 178 | + type: 'object', |
| 179 | + properties: { |
| 180 | + name: { type: 'string' }, |
| 181 | + }, |
| 182 | + required: ['name'], |
| 183 | + additionalProperties: false, |
| 184 | + }) |
| 185 | + |
| 186 | + const description = buildToolDescription({ |
| 187 | + toolName: 'greet__greet', |
| 188 | + schema: mcpSchema, |
| 189 | + description: 'Call greet', |
| 190 | + endsAgentStep: true, |
| 191 | + }) |
| 192 | + |
| 193 | + expect(description).toContain('greet__greet') |
| 194 | + expect(description).toContain('Params: {') |
| 195 | + expect(description).toContain('allOf') |
| 196 | + expect(description).toContain('name') |
| 197 | + expect(description).not.toContain('Params: None') |
| 198 | + }) |
| 199 | + |
175 | 200 | test('getToolSet handles custom tools with problematic schemas', async () => { |
176 | 201 | // Create a custom tool definition with a schema that can't be converted |
177 | 202 | const customToolDefs = { |
|
0 commit comments