defineTool()
Defines a tool that can be passed to models for automatic execution.Parameters
Registry
required
The Genkit registry instance
ToolConfig
required
Tool configuration object
ToolFn<I, O>
Implementation function for the toolFunction signature:
Returns
ToolAction
A tool action that can be passed to model generation requests
tool()
Defines a dynamic tool that is not registered in the Genkit registry.Parameters
Same asdefineTool() except without the registry parameter.
Returns
ToolAction
A dynamic tool action (not registered)
Tool Interrupts (Beta)
Tools can interrupt execution to request user confirmation or additional input.interrupt()
Creates an interrupt tool that pauses execution.ToolAction.respond()
Responds to a tool interrupt with output data.ToolRequestPart
required
The interrupt tool request to respond to
z.infer<O>
required
Response data matching the tool’s output schema
ToolResponsePart
ToolAction.restart()
Restarts a tool request after an interrupt.ToolRequestPart
required
The interrupt tool request to restart
any
Metadata to pass to the tool on restart (defaults to
true)ToolRequestPart