Practical Guide to Building Effective AI Agents and Workflows
Fred’s practical guide expands Anthropic’s “Build effective agents” by offering a technical selection framework, clear definitions of agents versus workflows, a suite of reusable design patterns such as prompt‑chain routing and orchestrator‑worker loops, real‑world case studies, and concrete implementation tips that emphasize simplicity, transparency, and effective tool‑prompt engineering.
Author Fred presents a practical guide based on Anthropic’s "Build effective agents", covering technical selection, design patterns, and implementation details for AI agents and workflows.
Core Content
The article enhances three core aspects: a technical selection guide that defines standards for choosing workflows or agents, an analysis of design patterns illustrated with real‑world scenarios, and expanded practical implementation points that turn theory into executable solutions.
Agent Overview
"Agent" is defined in multiple ways; Anthropic classifies them as class‑Agent systems and distinguishes them from pure workflows. Key terms such as "class Agent system", "workflow", and "intelligent agent" are clarified.
When to Use an Agent
Anthropic recommends the simplicity principle: seek the simplest solution and only add complexity when necessary. Important trade‑offs are discussed, noting that class‑Agent systems often exchange latency and cost for higher performance and should be evaluated carefully.
Guidelines for increasing complexity include choosing a workflow when tasks need predictability and consistency, and choosing an Agent when flexibility and dynamic model‑driven decisions are required. An important tip highlights that optimizing a single LLM call (through retrieval augmentation and contextual examples) is often sufficient.
Agent Framework Usage
Frameworks provide convenience but can hide prompt logic and LLM calls, leading to two main risks: difficulty debugging Agent systems built with frameworks and a tendency to over‑increase system complexity.
Practical advice: start with direct LLM API usage, understand the underlying framework thoroughly, and avoid incorrect assumptions about tool behavior.
Design Patterns
Several reusable patterns are described:
Prompt Chain + Routing : classify inputs then apply specialized prompt chains (e.g., customer‑service routing).
Routing + Parallelization : classify tasks and process complex cases with parallel evaluators and voting (e.g., content‑moderation).
Orchestrator‑Worker + Evaluator‑Optimizer : an orchestrator splits tasks, workers execute, and evaluators provide feedback for improvement (e.g., code generation).
Prompt Chain + Evaluator‑Optimizer : insert evaluation‑optimization loops at key points of a prompt chain (e.g., content creation).
Mixed Agent Systems : combine multiple patterns, selecting the best‑fit pattern for each stage of a task.
Each pattern includes a mechanism description and concrete examples such as intelligent customer service, content moderation, and programming agents.
Case Studies
Content moderation system using parallel evaluation and voting to balance false‑positive and false‑negative rates.
Literary translation optimization loop with multiple evaluation‑optimization iterations.
Programming Agent that solves SWE‑bench verified GitHub issues, demonstrating measurable success metrics.
Implementation Guidelines
Three core principles for Agent development: maintain simplicity, ensure transparency of planning steps, and design well‑documented tool interfaces (ACI). Emphasis is placed on reducing abstraction layers when moving to production.
Tool Prompt Engineering (Appendix 2)
Tool prompt engineering is defined as designing tool definitions so that LLMs clearly understand their purpose, usage, and output semantics. Basic principles include clear expression, concise formatting, and minimizing token overhead.
Three format‑selection principles are recommended: provide sufficient thinking space, use natural‑language‑like formats (Markdown, plain text), and minimize format burden (avoid precise counting or complex escaping).
Appendix 1: Agent Practical Value Criteria
Agents deliver maximum value when tasks require a blend of dialogue and action, have clear success metrics, support effective feedback loops, and incorporate meaningful human supervision.
Practical Advice
Start simple, evaluate performance, and only add complexity when data shows a clear benefit. Monitor interfaces, define quantitative success metrics, and balance cost versus latency.
Code Snippets
1. 暴力威胁:低阈值(高敏感度) 1. 并行评估结果: 1. 并行LLM提示(专注不同维度) 1. 并行评估结果:Tencent Technical Engineering
Official account of Tencent Technology. A platform for publishing and analyzing Tencent's technological innovations and cutting-edge developments.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.