Lecture 6 gives agent engineering a more useful vocabulary than “add an LLM loop.” It separates workflow patterns, reasoning and acting patterns, and context management patterns. These are composable choices about where control lives, how the model acts, and what it can see.
Key insights #
- Choose the least open-ended control flow that can handle the task; the five workflow patterns cover many problems without a free-form loop.
- ReAct, Reflexion, CodeAct, and plan-then-execute methods solve different reasoning and action problems.
- Context management is part of the algorithm: what the model sees affects every later decision.
- Pi shows how a minimal harness can be effective while leaving extension and safety decisions to its operator.
Five patterns before open-ended autonomy #

Source: CS329Z Lecture 6, PDF page 15.
The lecture follows Anthropic’s workflow taxonomy: prompt chaining, routing, parallelization, orchestrator-workers, and evaluator-optimizer. A chain passes one model result into the next step. A router chooses a specialized path. Parallelization splits independent work. An orchestrator decomposes a task and assigns workers. An evaluator scores or critiques an output and drives another attempt.
The developer still controls the larger workflow. Real systems can combine several patterns; the design question is which decisions need model judgment and which can be fixed in code.
The slides make each workflow’s fit conditions explicit. Chaining helps when a task has stable stages, at the cost of latency. Routing fits inputs that deserve different prompts or models. Parallelization can mean independent sections or several answers for voting. Orchestrator-workers fits tasks whose subtasks cannot be listed in advance. Evaluator-optimizer needs clear, reliable feedback; otherwise its loop amplifies noise.
STORM illustrates a structured research pipeline: find related material, generate perspectives and questions, gather evidence, then synthesize an article. Archon explores combinations of sampling, ranking, and fusion. Both show how composition can improve results without unrestricted autonomy at every substep.
Four ways an agent can think and act #
ReAct interleaves reasoning with environment actions. The paper argues that reasoning helps update a plan while actions supply fresh evidence. Reflexion stores linguistic feedback from an attempt so a later attempt can avoid the same mistake; the assigned paper learns through a memory buffer rather than changing model weights. The lecture adds a caution: unsupported self-criticism can make an answer worse, so external feedback matters.
CodeAct uses executable code as an action format, making it easier to compose operations than with a narrow list of JSON calls. That flexibility also requires an execution environment and clear boundaries. ReWOO plans tool steps before carrying them out, reducing repeated model calls when the plan can be executed with less interaction. The common theme is a tradeoff between adaptability and control: reasoning at every step can react to surprises, while planned execution may be cheaper and easier to inspect.
ReAct is valuable when observations should change a plan. Reflexion is useful when the agent can retry and receives informative feedback. The lecture’s CRITIC example uses external tools in verification, underlining that a second ungrounded model opinion is not an independent check.
The slides add LLMCompiler as a related plan-and-execute approach that can run independent calls in parallel and replan when observations demand it. This is a middle ground: the model helps make a plan, while the execution graph is constrained enough to schedule and inspect.
The context is a managed resource #

Source: CS329Z Lecture 6, PDF page 61.
Long-running agents accumulate observations. The lecture compares several ways to keep history usable: a persistent event log, offloading information into memory or files, compaction, masking bulky observations, and isolating context so a worker sees only what it needs. Progressive disclosure of instructions or skills delays material until it becomes relevant. Each method changes what the model may know at the next decision, so it should be tested as part of system behavior.
These context methods can be combined. An event log can preserve full history while the prompt builder masks old tool outputs. Offloading resolved facts to a file frees space before compaction. A subtask can then get isolated context. Aggressive masking or summarization saves tokens but can erase evidence needed for recovery.

Source: CS329Z Lecture 6, PDF page 80.
The Pi harness case study makes the abstractions tangible. Pi uses a minimalist ReAct-style loop, JSON tool calls, a conversation tree, skill files, and compaction. Its small core makes extension possible, but the slides point out that permissions and other operational safeguards are not built in. “Minimal” is therefore a design choice with responsibilities attached, not a synonym for production readiness.
Pi’s default tools—read, write, edit, and bash—also illustrate progressive disclosure: it can load a skill file when needed instead of carrying every instruction at once. The branching conversation tree lets an operator return to an earlier point and pursue another thread. Pi runs with its process’s permissions, so the deployment environment is part of its safety design.
My takeaway is to specify three things for any agent: who owns control flow, what feedback changes the next action, and what context survives between actions. Those decisions often matter more than the framework logo.
Further reading #
- Lecture 6 slides and video with captions
- Yao et al., ReAct
- Anthropic, Building Effective Agents
- LangChain, Context Engineering
- Shinn et al., Reflexion; Wang et al., CodeAct