Signal · API
defineTool
defineTool defines a tool from a name, a description, a Zod schema for its input, and an execute function. Signal sends the model the name, the description and the input schema converted to JSON Schema (parameters); execute is never sent. The model’s reply is scripted and makes no tool call; no model is called.
defineTool({
name: 'seatsLeft',
description: 'How many seats are left on a night',
input: z.object({ night: z.string().describe('The night, as YYYY-MM-DD') }),
execute: ({ night }) => ({ night, left: seatsLeftOn(night) }),
})[
{
type: 'function',
function: {
name: 'seatsLeft',
description: 'How many seats are left on a night',
parameters: {
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'object',
properties: {
night: {
type: 'string',
description: 'The night, as YYYY-MM-DD',
},
},
required: ['night'],
additionalProperties: false,
},
},
},
]Runs in this page on the installed package. The input and the expected output are defined by the example.