Skip to content

Conversation

@vaishnavyogesh
Copy link
Contributor

Description

This PR adds concurrent tool execution, allowing independent tools to run in parallel instead of sequentially. This significantly reduces latency when LLMs execute multiple tools that perform I/O operations like API calls or database queries.

Tools can be marked with ->concurrent() to execute in parallel:

$weatherTool = Tool::as('get_weather')
    ->using(fn ($city) => Http::get("weather.api/{$city}"))
    ->concurrent(); // Runs in parallel

$newsTool = Tool::as('get_news')
    ->using(fn ($topic) => Http::get("news.api/{$topic}"))
    ->concurrent(); // Runs in parallel

When an LLM calls both tools, they execute simultaneously instead of sequentially, reducing total execution time from (the slowest tool's duration).

The implementation uses Laravel's Concurrency driver, preserves event ordering in original tool call order. Works with both streaming and non-streaming responses.

Breaking Changes

None. This feature is fully backward compatible and opt-in. All existing tools continue executing sequentially by default.

@vaishnavyogesh vaishnavyogesh marked this pull request as draft January 26, 2026 05:55
@vaishnavyogesh vaishnavyogesh marked this pull request as ready for review January 26, 2026 06:02
@vaishnavyogesh vaishnavyogesh force-pushed the feat/concurrent-tools-execution branch from 30b0265 to f1bd7ea Compare January 26, 2026 06:07
@vaishnavyogesh vaishnavyogesh force-pushed the feat/concurrent-tools-execution branch from f1bd7ea to 4d264e0 Compare January 26, 2026 06:10
Copy link
Contributor

@sixlive sixlive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sick! Thanks!

@sixlive sixlive merged commit 5e45b95 into prism-php:main Jan 26, 2026
14 checks passed
@vaishnavyogesh vaishnavyogesh deleted the feat/concurrent-tools-execution branch January 27, 2026 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants