Agentic AI · Advanced level

Advanced level · Module 3: Sequential and Parallel Workflows · Lesson 2 of 3

Parallel Agents: Fan-Out and Fan-In

Learners run independent agents at the same time (for example searching several document collections or analysing several datasets) and merge their results.

In this lesson you will

  • Run independent agent tasks in parallel
  • Merge parallel results and resolve conflicts

Key concepts

fan-outfan-inasyncio.gathermerge functionconflicting evidence

The lesson

When tasks do not depend on each other, running them in parallel reduces waiting time. In Python, asyncio.gather runs asynchronous calls together; orchestration frameworks support fan-out to several nodes and fan-in to a merge step.

The merge step combines results: deduplicate passages, align figures and flag conflicts (two documents give different dates). Conflicts are reported, not silently resolved.

Parallel work multiplies cost and can hit rate limits faster, so cap the number of parallel tasks.

Step by step

  1. Split retrieval across three document collections.
  2. Run the three searches in parallel with asyncio.gather.
  3. Write a merge function that deduplicates and flags conflicts.
  4. Compare time and cost with sequential searching.

Practice activity

Add parallel retrieval with merging to the capstone.

Expected result: Faster retrieval, correct merging and visible conflicts.

Check your understanding

  1. When can agent tasks run in parallel?

    Show answer

    When they do not depend on each other's outputs.

  2. What should a merge step do with conflicting evidence?

    Show answer

    Report the conflict rather than silently choosing one side.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.