Skip to content
AgenticAIWiki
  1. Learn
  2. Part 8
  3. 41. Workflow patterns
  4. 41.3

Lesson 41.3 · 3 of 5 · 6 min read · Reviewed 24 Nov 2026

Parallelization: sectioning and voting

By the end, you can

  • Tell sectioning and voting apart.
  • Explain how parallelization differs from orchestrator-workers.

ParallelizationParallelization: A workflow pattern that runs several LLM calls at once, either on separate subtasks or as multiple votes on one task. runs several LLMLarge language model (LLM): A neural network trained on large amounts of text to predict the next token, which lets it generate and transform language. calls at the same time and combines their results with code. It comes in two forms.

Sectioning

Split the work into independent parts with separate, focused prompts. For example, when reviewing a marketing draft, one call checks tone, one checks factual claims and one checks policy. Each prompt can be precise, and the three run concurrently, so total latencyLatency: The time from sending a request until you get the response, or until the first token arrives when streaming. is roughly the slowest single call.

A common use is guardrailsGuardrail: A control that keeps an AI system within safe and allowed behaviour, such as input checks, tool limits or output filters.: one call handles the user’s request while another screens it for policy problems.

Voting

Run the same task several times, or with differently worded prompts, and compare. Useful when you want confidence: flag code as vulnerable only if two of three reviews agree, or tune the threshold to trade false positives against misses.

Parallelization vs orchestrator-workers

In parallelization, you decide the split when you write the code. If the number and kind of subtasks depend on the input, the split must happen at run time, which is the next pattern.

Key points

  • Sectioning runs different parts of a task at the same time.
  • Voting runs the same task several times and compares answers.
  • The split is fixed in code; results are combined in code.
Hands-on labRuns in the Playground

Run sections and votes in parallel

Use asyncio.gather to run sectioned checks at the same time and to take a two-of-three vote.

You will have: A script that prints the combined review of a draft and a vote result, with the simulated time saved by running in parallel.

Steps

  1. Read the stand-in async reviewers: each sleeps for a simulated time and returns a finding.
  2. Sectioning: run the tone, facts and policy checks together with asyncio.gather and combine their findings.
  3. Compare the simulated time with running them one after another.
  4. Voting: run the same vulnerability check three times with different prompts and flag only if at least two agree.
  5. Print both results.

Done when

  • All three section findings appear in the combined review.
  • Parallel time is about the slowest single check, not the sum.
  • The snippet is flagged only when at least 2 of 3 votes say vulnerable.

Open in the Playground No API key needed.

Starter code (Python)
import asyncio

async def check(name, seconds, finding):
    await asyncio.sleep(seconds)          # simulated model latency
    return name, finding

async def vote(prompt_variant, code):
    await asyncio.sleep(1)
    return "eval(" in code and prompt_variant != "lenient"   # stand-in for a model's judgement

async def main():
    draft = "Our new plan is the cheapest on the market and guaranteed to double your savings."
    # TODO: run the three section checks together with asyncio.gather
    # TODO: run three votes on the code snippet and flag if at least 2 agree
    print("TODO")

asyncio.run(main())
Show a solution
import asyncio

async def check(name, seconds, finding):
    await asyncio.sleep(seconds)          # simulated model latency
    return name, finding

async def vote(prompt_variant, code):
    await asyncio.sleep(1)
    return "eval(" in code and prompt_variant != "lenient"   # stand-in for a model's judgement

async def main():
    sections = [("tone", 2, "too pushy in sentence 1"), ("facts", 3, "'cheapest on the market' needs a source"),
                ("policy", 1, "'guaranteed' breaks the claims policy")]
    results = await asyncio.gather(*(check(*s) for s in sections))
    for name, finding in results:
        print(f"{name}: {finding}")
    print(f"simulated time: parallel ~{max(s[1] for s in sections)}s vs sequential {sum(s[1] for s in sections)}s")

    code = "result = eval(user_input)"
    votes = await asyncio.gather(*(vote(v, code) for v in ["strict", "neutral", "lenient"]))
    yes = sum(votes)
    print(f"votes vulnerable: {yes} of 3 -> {'FLAG' if yes >= 2 else 'pass'}")

asyncio.run(main())
Quick checkYou flag code as vulnerable only when two of three independent reviews agree. Which pattern is this?
How sure are you?
Pick an answer and how sure you are