Building Effective Agents (Anthropic Engineering)
Source: https://www.anthropic.com/engineering/building-effective-agents
This is the canonical reference for agentic patterns and should be re-read end-to-end before the exam.
Workflows vs Agents (architectural distinction)
- Workflows: "LLMs and tools are orchestrated through predefined code paths."
- Agents: "LLMs dynamically direct their own processes and tool usage."
When to build agentic systems
"Agentic systems often trade latency and cost for better task performance."
Start simple. Increase complexity only when demonstrably beneficial. Workflows suit well-defined predictable tasks. Agents excel when flexibility and model-driven decision-making are required.
The five workflow patterns
1. Prompt chaining
Decomposes a task into sequential steps with programmatic gates between them. Example: "generating marketing copy, then translating it." Gates catch failures before they propagate.
2. Routing
Classifies inputs and directs them to specialized handlers. Example: customer service queries routed by type; complex vs simple questions routed to differently-sized models.
3. Parallelization
Two variations:
- Sectioning: split independent subtasks; run in parallel.
- Voting: run the same task N times; consensus / majority.
Example: "multiple prompts evaluating content" for balanced false positive/negative tradeoff.
4. Orchestrator-workers
A central LLM dynamically breaks tasks into worker-delegated subtasks. Unlike parallelization, "subtasks aren't pre-defined, but determined by the orchestrator based on the specific input."
5. Evaluator-optimizer
One LLM generates; another evaluates iteratively. Most effective "when we have clear evaluation criteria."
Autonomous agents
Agents handle open-ended problems where step counts cannot be predicted. They "plan and operate independently, potentially returning to the human for further information." Critical: agents need ground truth from the environment at each step to assess progress.
Agents enable sophisticated capabilities but demand:
- Extensive testing.
- Appropriate guardrails.
- Careful toolset design.
Three core principles
- Simplicity in design.
- Transparency — show planning steps.
- Tool Documentation and Testing — invest in the agent-computer interface (ACI).
Tool engineering best practices
Anthropic recommends equal investment in tool definitions as in prompts:
- Format selection: prioritize natural presentation over technical convenience.
- Clear parameter documentation with examples and edge cases.
- Test tool usage extensively before deployment.
- Apply "poka-yoke" (mistake-proofing) — make misuse hard.
"During SWE-bench development, the team spent more time optimizing our tools than the overall prompt."
A specific example: they switched from relative to absolute filepaths to eliminate path-resolution errors. Small interface choices like this dominate quality.
Quotes worth memorizing
- "Agentic systems often trade latency and cost for better task performance."
- "We've found that finding the simplest solution and only increasing complexity when needed is the most important principle when building with LLMs."
- "We strongly recommend investing time in tool documentation and testing — the same care you'd put into prompt engineering."