Skip to content

2.5.4

Choose a tag to compare

@ilvalerione ilvalerione released this 09 Oct 10:52
· 333 commits to 2.x since this release

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.