diff --git a/packages/agent-runtime/src/__tests__/prompts-schema-handling.test.ts b/packages/agent-runtime/src/__tests__/prompts-schema-handling.test.ts index c6fe9dd058..9fd64c73fc 100644 --- a/packages/agent-runtime/src/__tests__/prompts-schema-handling.test.ts +++ b/packages/agent-runtime/src/__tests__/prompts-schema-handling.test.ts @@ -202,7 +202,7 @@ describe('Schema handling error recovery', () => { expect(description).toContain('content') }) - test('buildToolDescription preserves MCP params when schema is represented as allOf', () => { + test('buildToolDescription preserves MCP params from converted schema', () => { const mcpSchema = convertJsonSchemaToZod({ type: 'object', properties: { @@ -221,8 +221,8 @@ describe('Schema handling error recovery', () => { expect(description).toContain('greet__greet') expect(description).toContain('Params: {') - expect(description).toContain('allOf') expect(description).toContain('name') + expect(description).toContain('cb_easp') expect(description).not.toContain('Params: None') }) diff --git a/packages/agent-runtime/src/templates/prompts.ts b/packages/agent-runtime/src/templates/prompts.ts index d4e96faa03..459736941d 100644 --- a/packages/agent-runtime/src/templates/prompts.ts +++ b/packages/agent-runtime/src/templates/prompts.ts @@ -16,7 +16,11 @@ function ensureJsonSchemaCompatible(schema: z.ZodType): z.ZodType { return schema } catch { const fallback = z.object({}).passthrough() - return schema.description ? fallback.describe(schema.description) : fallback + try { + return schema.description ? fallback.describe(schema.description) : fallback + } catch { + return fallback + } } } diff --git a/packages/agent-runtime/src/tools/prompts.ts b/packages/agent-runtime/src/tools/prompts.ts index 9465a3c456..25ecfccdda 100644 --- a/packages/agent-runtime/src/tools/prompts.ts +++ b/packages/agent-runtime/src/tools/prompts.ts @@ -43,7 +43,11 @@ function ensureJsonSchemaCompatible(schema: z.ZodType): z.ZodType { return schema } catch { const fallback = z.object({}).passthrough() - return schema.description ? fallback.describe(schema.description) : fallback + try { + return schema.description ? fallback.describe(schema.description) : fallback + } catch { + return fallback + } } }