generate or stream call.
Register default tools
- The
toolsoption exposes tools for every call. loopToolsandmaxStepToolsdefined on the agent act as defaults.- You can override any of them per call (
agent.generate({ tools, loopTools, maxStepTools })).
Automatic tool loop
WhenloopTools is enabled and at least one tool is available, AI Kit orchestrates the loop: after each toolCall, the corresponding tool executes and the conversation resumes until a final answer is produced. The result includes a loopTool flag for quick DX inspection.
Control knobs
loopTools?: boolean– enable or disable the loop (disabled by default).maxStepTools?: number– cap the total amount of tool executions (default:20).- Override both on individual calls when you need a specific behaviour.
Recommendations
- Prefix tool IDs (
search.customer,support.lookup) to simplify monitoring. - Lower
maxStepToolswhen a tool can trigger expensive side effects. - Log
toolCallsin your observability stack to audit model decisions.