5 LLM Agent Patterns for Reliable, Bloat-Free Workflows
Use prompt chaining, routing, parallelization, orchestrator-workers, and evaluator-optimizer patterns to build production-ready LLM agents; start with simple workflows unless tasks demand adaptive reasoning, prioritizing tool interfaces, docs, and logging.
Match Patterns to Task Demands for Efficiency
Select LLM agent patterns based on four factors: task predictability, cost, latency, and complexity. For predictable tasks with fixed paths, default to workflows over full agents to avoid bloat—prompt chaining sequences calls deterministically, routing directs inputs to specialized sub-prompts (e.g., classify query then dispatch), and parallelization runs independent calls concurrently to slash latency without added reasoning overhead. These keep costs low (no extra tokens for planning) and scale for high-volume, structured work like data processing or multi-step analysis.
Switch to adaptive agents only when fixed paths fail: orchestrator-workers decomposes tasks into a central planner coordinating specialist worker LLMs (reduces single-model cognitive load, handles branching logic), while evaluator-optimizer iterates with self-critique loops—generate output, score against criteria, refine until passing (boosts accuracy 20-50% on complex reasoning but multiplies latency and cost 3-5x). Evidence from Anthropic papers shows these outperform naive single-shot prompting on benchmarks like multi-hop QA.
Build Production-Ready Systems with ACI and Observability
Design tools via Anthropic's ACI (Action-Context-Input) interface: define clear schemas for actions (what it does), context (preconditions), and inputs (params with types/validation), preventing hallucinated misuse. Pair with transparent logging—capture every prompt/response/tool call in structured JSON for debugging—and comprehensive docs explaining pattern trade-offs (e.g., chaining: zero reasoning cost but brittle to edge cases). This 'start simple' heuristic, drawn from CCA-F exam materials, ensures reliability: test patterns incrementally, measure token usage/latency, and fallback to simpler alternatives if agents underperform.