Skip to content

Passing .nullable to tool parameters always sends them to LLM as REQUIRED #208

@jdetera

Description

@jdetera
const myTool = createTool({
  name: 'my_tool',
  description: 'Tool with nullable enum parameter',
  parameters: z.object({
    paramA: z.enum(['active', 'inactive', 'pending'])
      .nullable()
      .describe('The status of the item, or null if not specified'),
    paramB: z.string(),
  }),
  handler: async ({ status, userId }) => {
    // status can be null here
    if (status === null) {
      // Handle null case
    }
    return { success: true };
  },
});

Even though being .nullable(), if you look at LLM call (Openai) the tool has:

required: [
"paramA",
"paramB"
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions