fix: ensure tool parameters schema is always a valid JSON Schema object
Problem: OpenAI API error 'got type: None' when tool has no/invalid parameters Solution: Add guard to explicitly create empty object schema with description when no parameters exist 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8f3c6a2910
commit
4705af6b1a
1 changed files with 6 additions and 1 deletions
|
|
@ -95,7 +95,12 @@ export function createToolDefinition(tool: Tool) {
|
|||
const parameters = Array.isArray(tool.parameters)
|
||||
? (tool.parameters as unknown as TPMJSParameter[])
|
||||
: [];
|
||||
const schema = tpmjsParamsToZodSchema(parameters);
|
||||
|
||||
// Ensure we have a valid schema - if no parameters, use an empty object with explicit additionalProperties
|
||||
const schema =
|
||||
parameters.length > 0
|
||||
? tpmjsParamsToZodSchema(parameters)
|
||||
: z.object({}).describe('No parameters required');
|
||||
|
||||
return aiTool({
|
||||
description: tool.description,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue