Skip to content

1.3 Agent Patterns and Frameworks

A workflow pattern is a standard way to arrange model calls and code. Sub-skill 1.1 decided the tier; this sub-skill names the shapes inside it. Memory is state an agent keeps and reads back. A framework is a library supplying pre-built loop, state and orchestration machinery.

Take a bed shop that sells mattresses online and wants to automate listings and customer emails.

Prompt chaining splits a task into a fixed sequence where each call works on the previous output, with optional programmatic gates between steps. The shop’s listings fit: draft, check, shorten. Routing classifies an input and sends it to a specialised follow-up: a different prompt, tool set or model per category. Delivery, returns and mattress-advice emails each get their own prompt.

Parallelization runs model work simultaneously in two forms. In sectioning, independent subtasks run side by side, such as a listing’s price and size checks. In voting, the same task runs several times for diverse or confident answers.

Orchestrator-workers has a central model break the task down at runtime and delegate to workers. It is the pattern behind subagent architectures. Its signature is that the subtasks are not known in advance. A customer’s question about delivery dates and monthly payments needs lookups the model finds only by reading it. Evaluator-optimizer pairs a generator with an evaluator that scores output against explicit criteria. The critique goes back until the result passes, as with listings graded on the shop’s checklist.

The mechanism separates four easily confused pairs.

  • Chaining versus routing: a fixed sequence versus a classification decision. If every input takes the same steps, chain; if categories deserve different treatment, route. Every listing takes the same steps; the emails do not.
  • Sectioning versus orchestrator-workers: subtasks known in advance versus decided at runtime by the model. Enumerable, independent parts need no orchestrator. The listing checks are enumerable; the delivery question is not.
  • Voting versus evaluator-optimizer: independent repeated attempts aggregated by code versus a feedback loop where the evaluator’s critique drives the next generation. Voting never converges on anything; it only aggregates, because no information passes between attempts.
  • A gate versus evaluator-optimizer: a gate is a fixed pass/fail checkpoint in a one-way sequence; the evaluator-optimizer loops back with a critique.

The simplest-thing rule from 1.1 covers all of it: the requirement profile justifies a pattern, never sophistication.

An agent remembers nothing between sessions unless the design adds a mechanism. In-context memory is the conversation itself: free until the window fills, gone when the session ends. External memory keeps working state outside the window.

Anthropic’s memory tool is now generally available on the Messages API as tool type memory_20250818. It gives Claude create, read, update and delete operations over files in a /memories directory. Claude requests each operation and your application executes it client-side. The agent builds up state across sessions and references earlier work without holding it all in context. The context-engineering post calls this structured note-taking: persist notes outside the window, read them back on demand. Session resume is related but distinct: it restores one specific conversation, whereas memory files carry curated state into any future session. A memory file could carry a shop customer’s chosen mattress size into any later chat.

Because your application executes every memory command, the safeguards live in your handler. The /memories path is a prefix your handler maps onto real storage, such as a per-user directory. The docs say it must reject paths outside it: resolve each path to its canonical form, reject ../ sequences and watch for URL-encoded ones such as %2e%2e%2f. As of September 2026 they also suggest tracking file sizes and capping how many characters a view returns, letting Claude page through the rest with view_range.

For long-horizon work across sessions, the docs describe a multisession pattern: each new session opens by reading a progress log from memory rather than re-exploring the codebase. One rule keeps that log honest: mark a feature complete only after end-to-end verification confirms it works, not when the code is written.

Context is a finite resource, and recall degrades as token counts grow; Anthropic’s engineering guidance calls this context rot. Long-running agents need a design answer. The documented moves are compaction, structured note-taking and sub-agent architectures. Compaction summarises the conversation and starts a new window with the summary, which the Agent SDK does automatically. A focused subagent explores in a clean window, say a month of the shop’s orders, and returns only a condensed summary.

On the Messages API, as of September 2026, compaction comes in two beta forms. On demand, your code requests the summary and swaps it in. At a token threshold, the API compacts once input tokens reach a trigger you set. The docs say to use on-demand compaction where available.

LangGraph is a low-level orchestration framework and runtime for building long-running, stateful agents. It comes from LangChain Inc but works without LangChain. Its pitch: model agent control flow explicitly as a graph, mix deterministic steps with model-driven ones, resume durable executions, and inspect state with a human in the loop. Pydantic AI is the typed Python agent SDK from the Pydantic team: give the agent an output type and every run comes back validated against it. Strands Agents is an open-source agent SDK for Python and TypeScript, built from production systems inside Amazon. Its approach is model-driven: the model drives the loop and orchestration code stays minimal.

A framework buys that machinery at the price of a dependency and an abstraction between you and the model. The simplest-thing rule applies to tooling too: plain code beats a framework for a fixed pipeline, and a framework must earn its abstraction cost. The shop’s listing chain needs no framework.

Selection items give a requirement profile and reward the pattern whose mechanism matches, with the adjacent pattern as the distractor. Brute force (run everything, run it bigger) is a recurring distractor. Memory items reward explicit persistence over hoping the window holds. A closing tooling question asks which framework, if any, a stated need points at. The guide names three agentic abstraction frameworks as examples, and items test matching a need to the framework that leads with it, never API trivia.

The exam takes its pattern names verbatim from Anthropic’s “Building effective agents”, American spellings included.

A subtitling team automates broadcast subtitle files. Every file must meet a published style code covering line length, reading speed and terminology. They want one model call to draft the file and a second call to grade it against the style code, feeding the critique back until the draft passes or three rounds elapse. Which workflow pattern is this?

  • A. Parallelization in its voting form: draft each file three times and keep the majority output
  • B. Prompt chaining with a programmatic gate: fixed draft, verify and publish steps, rejecting files that fail the style code check
  • C. Orchestrator-workers: a lead model decomposes the episode and delegates each subtitle file to a worker agent
  • D. Evaluator-optimizer: one call drafts the subtitle file, a second grades it against the style code, and the feedback loops until it passes
Answer & explanation

Correct: D

  • A — Voting aggregates independent attempts with no feedback between them. It never grades against the style code and cannot converge on a compliant draft.
  • B — A gate is a fixed pass/fail checkpoint in a one-way sequence. The stated requirement loops the critique of a model back into regeneration, which a gated chain never does.
  • C — Nothing here requires runtime decomposition. The subtasks are known (draft, grade, revise) and the requirement is a quality loop, not dynamic delegation.
  • D — Explicit evaluation criteria plus iterative refinement driven by evaluator feedback is exactly the evaluator-optimizer profile, and the bounded round count is a standard loop guard.