Scatter-Gather Tool

Fan out to multiple sources, then combine results.

category: Tool Composition
arcade.dev/patterns

Context

Querying multiple systems for related data.

Problem

Gathering data from multiple sources requires multiple sequential calls.

Solution

Scatter-Gather pattern:
- Fan out: Query multiple sources in parallel
- Gather: Combine results into unified response
- Handle failures: Partial results if some fail
- Deduplicate: Merge overlapping data

Examples

Python
@tool
async def search_all_repositories(
    query: str
) -> UnifiedSearchResult:
    """Search across GitHub, GitLab, and Bitbucket.
    
    Queries all configured repositories in parallel
    and returns unified results.
    """
    results = await asyncio.gather(
        search_github(query),
        search_gitlab(query),
        search_bitbucket(query),
        return_exceptions=True
    )
    return merge_results(results)

Considerations

  • Set timeouts for individual sources
  • When appropriate, return partial results if some sources fail
  • Indicate which sources contributed to results
  • For long running queries, return a job ID and instructions for how to check the status and retrieve the results

Related Patterns

More in Tool Composition