All labs · Lab 44 · advanced · 45 min

Many workers, one dispatcher

Process a batch of claims in parallel with a cap on how many run at once, retries for the ones that fail, and no claim lost.

You build: fanout.py: 20 claims, at most four at a time, each with a final result.

  • Python 3.11 or newer and uv
  • An OpenRouter key (free models are enough)
  • Lab 14 done (the extractor)
  1. 01Make 20 claim emails and process them one after another, timed

    time uv run --with openai --with pydantic fanout.py claims/ --max 1

    You pass when: 20 results and a total time. This is the number to beat.

  2. 02Run them four at a time

    time uv run --with openai --with pydantic fanout.py claims/ --max 4

    You pass when: The same 20 results in well under the first time. The log never shows more than four in flight.

  3. 03Make one call in five fail at random, and retry twice with a growing wait

    A batch that reports 18 of 20 with no word on the other two is the failure that reaches customers.

    uv run --with openai --with pydantic fanout.py claims/ --max 4 --chaos 0.2

    You pass when: Every claim ends as done or as failed after three tries. The count of both adds up to 20.

  4. 04Print a summary: done, retried, failed, total cost

    uv run --with openai --with pydantic fanout.py claims/ --max 4 --chaos 0.2 --summary

    You pass when: Four numbers, and the ids of any claim that failed for good.

The check runs on the computer, not on your word: a step passes when its command exits with 0 there.

Your computer · Fleet · off

Computers are not set up on this site yet. Run each command on your own machine and compare with "You pass when".