liveBook · Manning

Call_parallel

As explained in Designing AI Systems

call_parallel is a workflow API operation that invokes multiple child workflows concurrently and returns their results in submission order.

call_parallel() is a workflow-composition operation for independent child calls. It submits them concurrently through the gateway, waits for the results, and returns them in the input order instead of forcing the parent to process each request sequentially. section 9.4.2

Use call_parallel() when the parent workflow can fan out work without dependencies between child calls.

  • Provide a plain Python list of API paths and request bodies; the list may be built dynamically when earlier work discovers the required fan-out size. section 9.4.2
  • Receive results in submission order after the child calls complete, allowing predictable unpacking even when individual response times differ. section 9.4.2
  • Reuse call() behavior for retries and response modes; a child failure after retries propagates to the parent workflow. section 9.4.2

Research assistant fan-out

A research workflow sends the same topic to paper, news, and patent search workflows concurrently, unpacks the three ordered results, and passes them to a synthesis model. Each child workflow can scale and retry independently. section 9.4.2

Listing 9.16 Parallel calls to multiple child workflows
@workflow(
    name="research_assistant",
    api_path="/research",
    response_mode="sync",
    timeout_seconds=120,
    max_retries=2
)
def research_topic(topic):
    platform = GenAIPlatform()
 
    results = platform.workflows    \
        .call_parallel([    #A
            ("/search/papers",
             {"query": topic}),
            ("/search/news",
             {"query": topic}),
            ("/search/patents",
             {"query": topic}),
        ])
 
    papers, news, patents = results    #B
    
    synthesis = platform.models.chat(    #C
        model="o3",
        messages=[{"role": "user",
                   "content": f"Synthesize research"
                              f" on {topic}\n"
                              f"Papers: {papers['results']}\n"
                              f"News: {news['results']}\n"
                              f"Patents: {patents['results']}"}]
    )
 
    return {
        "report": synthesis.content,
        "sources": {
            "papers": papers["sources"],
            "news": news["sources"],
            "patents": patents["sources"]
        }
    }

Shows the workflow interface, dynamic request structure, ordered result unpacking, and synthesis step. section 9.4.2

Listing 9.17 Executing multiple workflow calls concurrently
from concurrent.futures import (
    ThreadPoolExecutor
)
 
def call_parallel(self, calls):    #A
    with ThreadPoolExecutor(
        max_workers=len(calls)
    ) as pool:
        futures = [
            pool.submit(    #B
                self.call,
                api_path,
                body
            )
            for api_path, body in calls
        ]
 
        results = []
        for future in futures:    #C
            results.append(
                future.result()
            )
        return results

Shows the thread-pool implementation that submits each call concurrently and collects futures in input order. section 9.4.2

How Designing AI Systems covers it

How deep it goes
Explains concurrent submission, ordered collection, retries, response modes, and failure propagation down to ThreadPoolExecutor internals.
Examples
Demonstrates concurrent searches across papers, news, and patents before synthesizing their results.
What it assumes
Assumes familiarity with workflow.call(), child workflows, gateway requests, and workflow response modes.
What you can do after
Apply it via workflow.call_parallel() to invoke independent child workflows concurrently and unpack results in submission order.
How it connects
Connects workflow composition with HTTP gateways, retries, response modes, asynchronous jobs, and parent-child workflows.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing AI Systems. The section links point to the parts of the book it draws on.