Cortex · Tools and gatesInvalid tool arguments (
Invalid tool arguments (input_invalid)
A tool call whose arguments fail the tool’s input schema produces an observation of kind error with code input_invalid. Arguments are parsed before execute, so execute is not called; the model receives the validation message as the tool result and the run continues. Here the model requests eight seats and the schema allows six; its turns are scripted and no model is called.
const book = defineTool({
id: 'book',
name: 'book',
description: 'Book seats for the member on a night',
riskLevel: 'medium',
input: z.object({ night: z.string(), seats: z.number().int().min(1).max(6) }),
execute: ({ night, seats }) => {
made.bookings += 1;
return { night, seats, left: seatsLeftOn(night) - seats };
},
});
const desk = defineAgent({
id: 'desk',
instructions: 'Book what the member asks for.',
tools: [book],
});
const result = await desk.run('Eight seats for Sunday, please.', { llm }).result;1 calls book {"night":"2026-10-25","seats":8}
2 writes {"response":"I can book six seats at most in one go. Shall I book six?"}{
observation: {
kind: 'error',
toolId: 'book',
args: { night: '2026-10-25', seats: 8 },
error: 'input_invalid: seats: Too big: expected number to be <=6',
},
toolResult: 'error: input_invalid: seats: Too big: expected number to be <=6',
bookingsMade: 0,
result: {
ok: true,
output: {
response: 'I can book six seats at most in one go. Shall I book six?',
},
},
}Runs in this page on the installed package. The input and the expected output are defined by the example.