読書:building-effective-agents
Agentsとは、LLMを使って動的にプロセスを決めて、ツールを使って、タスクを完成するシステムです。
シンプルのはベスト。必要の時だけAgentを作成。
Agentic systems often trade latency and cost for better task performance, and you should consider when this tradeoff makes sense.
workflows offer predictability and consistency for well-defined tasks, whereas agents are the better option when flexibility and model-driven decision-making are needed at scale.
- LangGraph from LangChain;
- Amazon Bedrock's AI Agent framework;
- Rivet, a drag and drop GUI LLM workflow builder; and
- Vellum, another GUI tool for building and testing complex workflows.
Building blocks
The augmented LLM: LLM enhanced with augmentations such as retrieval, tools, and memory
There are many ways to implement the augmentations, MCP allows developers to integrate with a growing ecosystem of third party tools with a simple client implementation.
Workflow: Prompt chaining.
Decomposes a task into a sequence of steps, where each LLM call processes the output of the previous one
Workflow is ideal for situations where the task can be easily and cleanly decomposed into fixed subtasks. The main goal is to trade off latency for higher accuracy, by making each LLM call an easier task.
Workflow:
Routing: classifies an input and directs it to a specialized followup task, for separation of concerns, and build more specialized prompts.
Parallelization: work simultaneously on a task and have their outputs aggregated programmatically.
- Sectioning: breaking a task into independent subtasks run in parallel
- Voting: running the same task multiple times to get diverse outputs
Orchestrator-workers: a central LLM dynamically breaks down tasks, delegates them to worker LLMs, and synthesizes their results.
Well suited for complex tasks, where you can't predict the subtasks needed. subtasks aren't pre-defined, but determined by the orchestrator based on the specific input.
Evaluator-optimizer: LLM call generates a response while another provides evaluation and feedback in a loop.
effective when we have clear evaluation criteria, and when iterative refinement provides measurable value.
Agents
Agents begin their work with either a command from, or interactive discussion with, the human user. Once the task is clear, agents plan and operate independently, potentially returning to the human for further information or judgement.
During execution, it's crucial for the agents to gain ground truth, from the environment at each step, to assess its progress. Agents can then pause for human feedback at checkpoints or when encountering blockers.
Implementation is often straightforward. They are typically just LLMs using tools based on environmental feedback in a loop. It is therefore curtial to design toolsets and their documentation clearly and thoughtfully.
when to use agents: used for open-ended problems where it's difficult or impossible to predict the required number of steps, and where you can't hardcode a fixed path.
It's about building the right system for your needs. Start with simple prompts, optimize them with comprehensive evaluation, and add multi-step agentic systems only when simpler solutions fall short.
Build Agent Cookbook
References
Source Blog: https://www.anthropic.com/engineering/building-effective-agents
https://github.com/anthropics/anthropic-cookbook/tree/main/patterns/agents
Agent uses
https://www.anthropic.com/engineering/swe-bench-sonnet
https://github.com/anthropics/anthropic-quickstarts/tree/main/computer-use-demo
