Loading
0x10Lesson 2 of 8

Workflows or agents? Choose the pattern

Pick the simplest design that works: prompt chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer - or a full agent.

20 min 5-question quiz 2 code exercises
By the end of this lesson you can
  • Tell workflows (fixed code paths) from agents (model-directed loops)
  • Match problems to the five common workflow patterns
  • Implement routing and parallel voting

Building effective agents draws a useful line: workflows orchestrate models and tools through predefined code paths; agents let the model direct its own process - which tools, how many steps. Agents suit open-ended problems where you can’t predict the steps; when you can, a workflow is cheaper, faster and easier to test. Start simple and add autonomy only when it pays off.

Five common workflow patterns:

PatternIdea
Prompt chainingfixed sequence of steps, each using the last one’s output, with checks between
Routingclassify the input, send it to a specialized handler
Parallelizationrun independent parts at once, or the same task several times and vote
Orchestrator-workersa central model splits the task dynamically and delegates the pieces
Evaluator-optimizerone model drafts, another critiques, repeat until the criteria are met

Try it

Which pattern fits?

Match each problem to the simplest design that solves it well.

0 of 6 sortedScore 0/0
  • “Support messages go to billing, technical or returns specialists”

  • “Write marketing copy, then translate it, always in that order”

  • “Three independent reviewers check content for policy violations, and you take the majority”

  • “A coding change touches an unknown number of files, decided after reading the code”

  • “Polish a translation until a reviewer finds no more issues”

  • “Investigate why production latency spiked, using logs, metrics and dashboards as needed”

route.py
1ROUTES = {"billing": ["refund", "charge"], "technical": ["error", "crash"]}
2message = "the app shows an error after the refund"
3scores = {route: sum(word in message for word in words) for route, words in ROUTES.items()}
4print(scores)
Output
{'billing': 1, 'technical': 1}

Key takeaways

  • Workflows follow code paths you define; agents choose their own steps.

  • Prefer the simplest pattern that works; add autonomy only when needed.

  • Chaining, routing, parallelization, orchestrator-workers and evaluator-optimizer cover most needs.

Lesson quiz

5 questions · pass with 4 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Practice: write Python

Write Python in the editor and run it against sample inputs. Python runs locally in your browser using a WebAssembly runtime.

Exercise 1

Route requests to handlers

+25 XP

Line 1 is a JSON object mapping routes to keyword lists. For each following request, count how many of each route’s keywords appear in the lowercased request. Print ROUTE: request for the route with the most matches (the earlier route wins ties), or general: request if nothing matches.

  • Four requests
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Exercise 2

Combine parallel reviewers

+25 XP

Each line is item|verdicts, where verdicts are comma-separated safe or unsafe from independent reviewers. Print ITEM: block if a majority say unsafe, ITEM: review if at least one but not a majority does, and ITEM: allow otherwise.

  • Three items
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…

Did you like the lesson? 😆👍
Consider a donation to support our work: