Skip to content

Commit 5816737

Browse files
committed
Fix Zod v4 schema description crash in agent-runtime
1 parent de0954c commit 5816737

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

packages/agent-runtime/src/__tests__/prompts-schema-handling.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ describe('Schema handling error recovery', () => {
202202
expect(description).toContain('content')
203203
})
204204

205-
test('buildToolDescription preserves MCP params when schema is represented as allOf', () => {
205+
test('buildToolDescription preserves MCP params from converted schema', () => {
206206
const mcpSchema = convertJsonSchemaToZod({
207207
type: 'object',
208208
properties: {
@@ -221,8 +221,8 @@ describe('Schema handling error recovery', () => {
221221

222222
expect(description).toContain('greet__greet')
223223
expect(description).toContain('Params: {')
224-
expect(description).toContain('allOf')
225224
expect(description).toContain('name')
225+
expect(description).toContain('cb_easp')
226226
expect(description).not.toContain('Params: None')
227227
})
228228

packages/agent-runtime/src/templates/prompts.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ function ensureJsonSchemaCompatible(schema: z.ZodType): z.ZodType {
1616
return schema
1717
} catch {
1818
const fallback = z.object({}).passthrough()
19-
return schema.description ? fallback.describe(schema.description) : fallback
19+
try {
20+
return schema.description ? fallback.describe(schema.description) : fallback
21+
} catch {
22+
return fallback
23+
}
2024
}
2125
}
2226

packages/agent-runtime/src/tools/prompts.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ function ensureJsonSchemaCompatible(schema: z.ZodType): z.ZodType {
4343
return schema
4444
} catch {
4545
const fallback = z.object({}).passthrough()
46-
return schema.description ? fallback.describe(schema.description) : fallback
46+
try {
47+
return schema.description ? fallback.describe(schema.description) : fallback
48+
} catch {
49+
return fallback
50+
}
4751
}
4852
}
4953

0 commit comments

Comments
 (0)