Free & open · no paywall, ever

IntegrAuth Academy

Identity, security and practical AI — free, from zero. Byte-sized lessons, real diagrams, hands-on labs, zero fluff. Two programs, each with its own exam and certificate.

20 tracks 241 lessons 242 hands-on labs 230+ diagrams 100% free

English is hard? Your browser can translate this page into Tamil, Telugu, Kannada, Malayalam or Hindi. Tech words stay in English so you learn the real names.

How?
  • Chrome on phone: ⋮ menu → Translate
  • Chrome on computer: right-click → Translate to …
  • Edge: the translate icon in the address bar
Practical AI Track 5 · Building with AI
0/75 lessons read
BUILDING WITH AI · LESSON 4

Agent design patterns

Priya's support agent made about 12 AI calls per ticket. Once, it searched orders for a password question. Your goal: pick the simplest design that does the job.

🧪 Interactive lab — enable JavaScript to play with this one.

Prompt chainingRoutingParallel: sectioningParallel: votingOrchestrator-workersEvaluator-optimizerInLLM 1checkLLM 2OutInRouterrefund prompttech promptsmall modelInpart Apart Bsafety checkcode mergesIntry 1try 2try 3voteInOrchestratorworkerworker… as neededInGeneratorEvaluatorOutfeedbackpassresultsfixed steps, with a check betweenclassify, then hand to a specialistindependent parts at the same timesame task several times; majority winsthe LLM decides the subtasks, then combinesdraft, critique, revise until it passes
Six shapes. Your code sets each shape. Only the orchestrator picks its own tasks.
Key points
  • Start with one good AI call. Test it first.
  • Each extra step adds calls, waiting and a place to fail.
  • Small errors add up over many steps.
  • Pick the least freedom that does the job.

Workflow or agent?

A train follows fixed rails. An auto-rickshaw driver picks each turn. In a workflow (Automations and agent builders), your code lays the rails, and the AI does each step. In an agent, the AI is the driver and picks each next step. A workflow fails in a place you can find. An agent can fail anywhere it went.

Both use one block: a model that can search, use tools and remember. This is an augmented LLM.

The shapes

ShapeHow it works
Prompt chainingSteps in order, with code checks between them.
RoutingOne call sorts the input. Each kind gets its own prompt or model.
SectioningNamed parts run at once. Code joins them.
VotingThe same task runs a few times. The most common answer wins.
Orchestrator-workersA lead AI splits this input into parts. Workers do them.
Evaluator-optimizerOne call drafts. Another checks it against clear rules, up to a round limit.

Agents showed the last two.

Climb only as far as you need

Measure one good call on an eval set first. Add a shape only when it is worth its cost.

You can mix shapes. Priya's new bot sorts each ticket, then runs a short chain with a check. About 1 in 10 tickets goes to an agent, with a person's OK.

Now plan: a step waits for what it needs. The rest can run at once.

🧪 Interactive lab — enable JavaScript to play with this one.

Go deeper: what the guide says

Anthropic's guide Building effective agents came out in December 2024. Many people now use its names for these shapes. It calls workflows "systems where LLMs and tools are orchestrated through predefined code paths". It calls agents "systems where LLMs dynamically direct their own processes and tool usage".

Its first advice is to find "the simplest solution possible". For many apps, it says, one good call with search and examples is usually enough. It suggests starting with the model's API directly. Many patterns take only a few lines of code. Frameworks can add layers that hide the real prompts and answers. You can read the guide yourself. It is short.

Go deeper: what each shape costs
  • Chaining: the wait adds up step by step. But each call gets an easier job, so answers are often more accurate.
  • Routing: easy questions can go to a smaller, cheaper model. But a wrong sort sends the input down the wrong path. Test the sorter, too.
  • Sectioning: more calls at once, so more cost and more rate limits. The wait is about the slowest part, not the sum.
  • Voting: you pay for every try. Tries from one model can share the same blind spot. Researchers call a similar idea self-consistency (Wang and others, 2022).
  • Orchestrator-workers: many calls and tokens. The result is only as good as the lead's plan. It looks like sectioning, but the AI names the parts, for each input.
  • Evaluator-optimizer: two calls every round. It needs a round limit and rules the checker can really check.
Go deeper: the agent loop

Agents, subagents and skills showed the loop. In code, it looks like this:

  1. Send the goal, the chat so far and the list of tools to the model.
  2. The reply asks for no tool? The model thinks it is done. Check that, then return the answer.
  3. It asks for a tool? Your code runs it, or refuses. Add the real result to the chat.
  4. Go back to step 1, unless a limit is used up: steps, tokens, money or time.

It needs limits it can't argue with. Use a step cap, a budget, and a person's OK before anything final. More freedom also means more outside text. Any tool result can carry prompt injection. So keep tools narrow. More in Build an agent.

Go deeper: why errors and costs add up
0%25%50%75%100%15101520number of steps in a row99% per step → 82%95% per step → 36%90% per step → 12%
Small errors, multiplied. This assumes steps fail on their own, with no fixes. Checks and retries push the lines back up.

Say each step is right 95% of the time, and steps fail on their own. Then 10 steps all go right 0.9510 ≈ 60% of the time. That is 0.95 multiplied by itself 10 times. With 20 steps, it is about 36%.

Three habits help. Use fewer steps. Add checks between steps, so an error is caught early. And make each step better. Going from 95% to 99% matters more than a clever design.

Cost adds up, too. Every call sends its context again (Cost, limits and caching). In June 2025, Anthropic said its agents used about 4 times as many tokens as a chat. Its multi-agent research system used about 15 times as many. That pays off only for valuable tasks that split well.

Watch out

A checker or voting panel that uses the same model can share its blind spots. Give it clear rules.