Agents & launch
Chapter 8 · Phase 7 · practice in Week 13 and Week 14
1. What is an LLM agent?
Chatbot vs agent
Chatbot
- Single LLM call per user message
- One response, no action
- Deterministic control flow
- User drives each step
- No external state changes
- Low risk per call
Agent
- Multiple LLM calls to complete a goal
- Takes real-world actions via tools
- LLM decides the next step
- Can operate autonomously for many steps
- Can write to databases, send messages, run code
- Higher risk — mistakes compound across steps
2. The agent loop
"Research and summarize all P0 incidents from last quarter"
"I need to: 1) query incident DB, 2) filter P0s, 3) retrieve details, 4) summarize"
query_incidents(severity="P0", since="90d")
Returns 12 incidents with IDs
"I have the list. Now fetch details for each to extract root causes."
3. Tool calling in agents
Tools are the agent's arms and legs. Each tool is a function your application exposes. The LLM decides which tool to call with which arguments; your code executes it and returns the result.
Common agent tool types
| Category | Examples | Risk level |
|---|---|---|
| Read-only | Search docs, query DB (SELECT), call read APIs | Low |
| Compute | Run Python, execute SQL, call calculators | Medium (sandbox required) |
| Write to DB | INSERT, UPDATE, DELETE | High (require confirmation) |
| External actions | Send email, post to Slack, create ticket | High (irreversible) |
| Code execution | Run arbitrary Python/shell | Critical (sandboxed only) |
4. Human-in-the-loop (HITL) gates
Not every agent action should run automatically. For high-stakes or irreversible actions, require human approval before execution.
Always gate
Sending communications (emails, Slack messages), modifying production data, running shell commands, making purchases. These are irreversible or high-visibility.
Gate when confidence is low
If the agent expresses uncertainty ("I'm not sure if X or Y is correct here"), pause and ask the user. Define a confidence threshold below which the agent must ask.
Never gate
Read-only queries, search operations, formatting operations. These can run freely — they have no side effects.
How the gate decision works
Before executing any tool call, the system checks two conditions: is this tool on the high-risk list (send email, delete record, post to Slack, run shell commands), OR did the agent express low confidence below a set threshold (typically 70%)? If either is true, the action is paused and a confirmation UI is shown to the user before anything runs. If the user declines, the action is cancelled and the agent receives that feedback so it can try a different approach. If neither condition is met, the action runs automatically without interruption.
The key PM decision is defining what goes on the high-risk list and setting the confidence threshold. Too many gates and the agent becomes annoying and slow. Too few and users lose trust the first time it does something they didn't expect.
5. Evaluating agents — multi-step evals
Agent evaluation is harder than single-call evals because the output is a sequence of steps, not just a final answer. You need to evaluate both the process and the result.
6. Production launch checklist
Shipping an LLM feature to production requires infrastructure beyond the prototype. Use this checklist before every launch.
Observability
Full request/response logging, latency metrics (p50/p95/p99), error rate dashboard, cost per user/session dashboard. Set alert thresholds before launch, not after.
Safety and content filtering
Implement input and output classifiers for harmful content. Define explicit policy for what the system will not do. Test with adversarial inputs before launch.
Rate limiting
Per-user and per-org token quotas. API provider rate limit handling (exponential backoff). Queue for burst traffic. Never let one user exhaust your API quota.
Rollback plan
Pin the model version and prompt version. Document how to roll back to the previous version in < 10 minutes. Test the rollback procedure before launch day.
Eval baseline
Run your eval suite against production before and after launch. Record the baseline scores. If post-launch scores drop, you have a regressions signal.
User-facing disclosure
Users must know they are interacting with AI. Label the feature clearly. For regulated domains (healthcare, legal, finance), include appropriate disclaimers.
Gradual rollout
Do not flip to 100% on day one. Start at 1% → 5% → 20% → 100% with a hold period at each stage. Monitor all metrics at each stage before expanding.
Test your understanding
Further reading & watching
- BlogChip Huyen — Agents, Tools & Control Flows (Part 2)The most direct mapping to this chapter: sequential/parallel/loop control flows, tool use, and how to test multi-step agents. Read Part 2 in full.
- BlogChip Huyen — Testing Agents & Composability Gap (Part 2)Explains the composability gap — the compounding failure risk that makes agents harder than single LLM calls. Critical PM awareness.
- BlogLilian Weng — LLM-powered Autonomous AgentsComprehensive survey of agent architectures, memory, planning, and tool use patterns. The definitive blog post on agents.
- VideoHarrison Chase — Building Agents with LangGraphLangChain co-founder walks through stateful multi-agent graph architectures.
- ResearchMETR — AI Agent EvaluationsResearch org measuring autonomous AI agent capabilities and risks.