Sometimes several agents share the work. Each agent has its own context, so the work can run in parallel.

Patterns

PatternHow it worksExample in the shopping task
Lead and workersA lead agent splits the task, and the workers run in parallelOne worker searches each shop
ReviewerOne agent drafts and another checksA reviewer checks the cart against the request
Buyer and sellerAgents from 2 organisations talk, using the A2A protocolOur agent asks the agent of the shop for a deal

Cost

  • more agents cost more
  • the research system of Anthropic, a lead agent plus helpers, beat a single agent by 90.2%, but it used about 15 times the tokens of a chat
  • start with one agent, and add more only for work that can truly run in parallel

Remembering tip

Lead and workers split the work, the reviewer checks it, and buyer and seller negotiate it.

Code

Lead and workers, with a thread pool as the parallel part:

from concurrent.futures import ThreadPoolExecutor
 
def worker(shop_name):
    """One worker agent searches one shop and returns a short summary."""
    return f"{shop_name}: best total 47.85"        # placeholder for a full agent run
 
shops = ["ShopA", "ShopB", "ShopC"]
with ThreadPoolExecutor() as pool:
    summaries = list(pool.map(worker, shops))      # workers run in parallel
 
lead_context = "\n".join(summaries)                # the lead keeps only the summaries

Notes: