2.5.4
Parallel Tool Calls
If your agents are tool-hungry, you can enable parallel execution if the model ask for multiple tool calls in a single request.
Just attach the ParallelToolCalls trait to your Agent:
class DemoAgent extends Agent
{
use ParallelToolCalls;
protected function provider(): AIProviderInterface
{
return new OpenAIResponses(
$_ENV['OPENAI_API_KEY'],
'gpt-4o-mini',
);
}
protected function tools(): array
{
return [
CalculatorToolkit::make(),
];
}
}To use this trait you need to install the spatie/fork package. For more information check out the GitHub repository: https://github.com/spatie/fork
Limitations
This implementation requires the pcntl extension which is installed in many Unix and Mac systems by default.
❗️ pcntl only works in CLI processes, not in a web context.