// Disable tools for this specific callWeatherAgent::for('chat-123') ->toolNone() ->respond('What is your name?');// Require at least one tool callWeatherAgent::for('chat-123') ->toolRequired() ->respond('What is the weather?');// Force a specific tool to be usedWeatherAgent::for('chat-123') ->forceTool('get_weather') ->respond('Check the weather in Paris');// Set tool choice programmatically$agent->setToolChoice('none');$agent->setToolChoice('required');$agent->setToolChoice('auto');
toolRequired() and forceTool() only apply to the first LLM call. After that, tool choice automatically switches to auto to prevent infinite loops.
forceTool() requires the tool’s name as a parameter, not the method or class name.
use LarAgent\Tool;// Add a tool class$agent->withTool(WeatherTool::class);// Add an inline tool instance$tool = Tool::create('get_time', 'Get current server time') ->setCallback(fn() => now()->toIso8601String());$agent->withTool($tool);
// Remove by tool name$agent->removeTool('get_weather');// Remove by class name$agent->removeTool(WeatherTool::class);// Remove by instance$agent->removeTool($tool);