Module 10: Agents in Production and Alternatives
1. Introduction: From prototype to production
Description
Module 9 solved a trust problem: your agent stopped being something that "seems to work" and became something that has evidence it works. With unit tests, you verify every tool and every edge of the StateGraph in isolation. With integration tests, you run the full agent loop against a real LLM and capture trajectories as snapshots. With trajectory evaluation, you assess not only whether the result is correct but whether the path was efficient — tool selection, sequence quality, reasoning. With golden datasets, you automate regression testing to catch degradations before the deploy. With LangSmith, you get an observability dashboard that shows every decision of every agent on every run. Research Agent v6 has 30+ unit tests, 5 integration tests, a golden dataset of 20+ queries, trajectory evaluation with LLM-as-judge, and baseline benchmarks that let you communicate performance with numbers: task completion rate, tool call accuracy, latency, cost per task. You know it works. You have the data to prove it. But there's a problem no test solves on its own: your agent works in your notebook. Does it work for 1,000 concurrent users?
This module closes the guide with the most practical — and most ignored — leap in the industry: from prototype to production. Most agents never leave the notebook. Not because they don't work — they do. But because nobody knows how to deploy them as a real service: REST endpoints that receive requests, async execution that doesn't block, health checks that verify every agent is responding, monitoring that alerts you when the error rate climbs, cost control that prevents a badly formed query from burning $50 in tokens. The gap between "my agent produces good reports in Jupyter" and "my agent serves a team of 20 analysts via API with a 30-second SLA" is enormous — and it's exactly what this module covers. Deployment with FastAPI and LangGraph Platform. Scaling with async execution, caching, and connection pooling. Monitoring with LangSmith in production, actionable alerts, and dashboards. Error recovery with graceful degradation, circuit breakers, and retry policies. Cost control with token budgets, per-user rate limiting, and cost-based model routing. Every pattern is implementable and justified with trade-offs — no hand-waving.
This module also includes something few guides offer at this depth: an honest comparison with Pydantic AI. You invested 9 modules learning the LangChain/LangGraph ecosystem. You deserve to know serious alternatives exist. Pydantic AI offers a radically different philosophy — extreme type-safety, dependency injection, fewer abstractions, more idiomatic Python — and for certain use cases it's the better option. You won't read a one-paragraph "Pydantic AI also exists." You're going to implement the same agent in both frameworks and compare: lines of code, type-safety, testing experience, performance, ecosystem. You leave with framework selection criteria, not brand loyalty. And beyond LangChain vs Pydantic AI, you get a general decision framework: when should you consider CrewAI? AutoGen? Semantic Kernel? The goal is that you pick tools with data, not with inertia.
Where are we in the guide?
Context
This guide has 10 modules organized into 3 phases:
Phase 1: Agent Foundations (Modules 1-3) ✓ COMPLETED
├── Module 01: Anatomy of an AI Agent ✓ COMPLETED
├── Module 02: Tool Use Fundamentals ✓ COMPLETED
└── Module 03: Function Calling Patterns ✓ COMPLETED
Phase 2: Agent Architecture (Modules 4-6) ✓ COMPLETED
├── Module 04: State Machines for Agents ✓ COMPLETED
├── Module 05: Multi-Step Reasoning and Planning ✓ COMPLETED
└── Module 06: Memory Systems for Agents ✓ COMPLETED
Phase 3: Advanced Integration & Production (Modules 7-10) ✓ COMPLETING
├── Module 07: MCP and Advanced Tool Integration ✓ COMPLETED
├── Module 08: Multi-Agent Orchestration ✓ COMPLETED
├── Module 09: Testing and Evaluation of Agents ✓ COMPLETED
└── Module 10: Agents in Production and Alternatives ← THIS MODULE (FINAL)
Last module of Phase 3. Last module of the guide. The capstone. Phases 1 and 2 built an agent with all its internal capabilities: tool use (M2-M3), flow control (M4), deliberative intelligence (M5), and persistent memory (M6). Phase 3 took that agent into the real world: external tools at scale (M7), multi-agent coordination (M8), formal testing (M9). One step is left: put it in production and close it with industry perspective (M10).
The progression of Phase 3 wasn't accidental — each module opened a door the previous one made possible:
- Module 7 — How it connects to the world → MCP servers, clients, dynamic tools, ecosystem ✓
- Module 8 — How it works as a team → Supervisor, handoffs, subagents, shared state ✓
- Module 9 — How you know it works → Unit tests, trajectory evaluation, golden datasets, regression ✓
- Module 10 — How you put it in production → Deployment, observability, costs, alternatives ← HERE
Where are you coming from?
Module 9 left you with a Research Agent v6 that has measurable evidence it works:
- 30+ deterministic unit tests: Every tool, every conditional edge, every state transition verified without an LLM. They run in seconds on every commit
- Integration tests with trajectory capture: The full agent loop executed against a real LLM, trajectories stored as snapshots for future comparison
- Trajectory evaluation with LLM-as-judge: You don't just verify the result is correct — you verify the agent used the right tools, in the right order, efficiently
- Golden dataset of 20+ queries: Automated regression testing that catches degradations before the deploy. CI/CD integration with alerts
- Baseline benchmarks: Task completion rate, tool call accuracy, avg latency, cost per task — numbers, not gut feelings
That's a multi-agent system tested and validated. You know it works. But when you look at how you run it, you still see this:
result = await research_system.ainvoke({
"task": "Research quantum computing applications in drug discovery"
})
print(result["final_report"])
# It works. It's tested. But it runs on my laptop.
# Who else can use it? Only me.
A notebook. A terminal. One user: you.
Where are you headed?
The transition from M9 to M10 is the leap from "a system that works and is validated" to "a system that serves real users." M9 gave you confidence — evidence that your agent behaves correctly. M10 puts it in the real world: REST endpoints any application can consume, async execution that doesn't leave users waiting, health checks that verify the system is alive, monitoring that alerts you when something breaks, and cost control that keeps your bill in check.
This is the end of the guide. There is no Module 11. After M10, you have a production-ready multi-agent system — deployed, monitored, with costs under control, and with the perspective to choose frameworks on your own terms. The journey that started with a hand-rolled ReAct loop in M1 ends with a system of 4 coordinated agents serving requests in production.
The production gap
Most agents never leave the notebook
There's a predictable pattern in this industry: an engineer builds a brilliant agent in Jupyter. Demos it. The team gets excited. And then... nothing. The agent stays in the notebook. Weeks pass. The agent is still in the notebook. Months pass. Someone asks "whatever happened to the research agent?" and the answer is "it works, but we haven't had time to deploy it."
It isn't a problem of technical ability. It's a problem of knowledge. Nobody taught them how to go from notebook to production. The gap is real and it has concrete pieces:
1. Deployment: "How do I expose it as a service?"
An agent.ainvoke() in a notebook is not a service. A service needs defined endpoints, documentation, health checks, graceful shutdown, environment configuration, secrets management, and containerization. Each one of these is a skill that most agent tutorials ignore completely.
2. Concurrency: "What happens when 50 requests arrive?"
In your notebook, one request at a time. In production, 50 users asking for research reports simultaneously. Each request fires 14+ LLM calls (4 coordinated agents), consumes tokens, occupies memory, waits on external APIs. Without async execution, connection pooling, and request queuing, your service collapses at 10 concurrent users.
3. Cost: "How much does this cost per month?"
A research query with 4 agents consumes 38,500 tokens ($0.30-0.80 with GPT-4.1). At 100 queries/day × 30 days = 3,000 queries/month, the estimated monthly cost is $900-$2,400. Without token budgets, rate limiting, and model routing, an agent in production can burn through the API budget in days. And worse: a query that triggers infinite loops can generate a $500 bill in a single run.
4. Observability: "How do I know it's working well?"
In production with 100 daily queries, you can't read every output. You need automatic metrics (latency, error rate, token usage), actionable alerts ("error rate > 10%"), per-request tracing for post-hoc debugging, and trend dashboards.
5. Resilience: "What happens when something fails?"
In production, everything fails eventually: LLM provider outages, downed MCP servers, expired API keys, unexpected tool errors, inputs that trigger edge cases. Without graceful degradation, circuit breakers, retry policies, and fallback strategies, every failure turns into a 500. In a multi-agent system, failure modes multiply: the failure can be in any agent, in the coordination, in the state, or in the infrastructure.
The gap is mindset, not difficulty
None of these problems is extraordinarily hard. FastAPI is an elegant framework. Async Python is mature. LangSmith has production features. Token budgets are arithmetic. But the combination of all of them — deployment + concurrency + cost + observability + resilience — is what keeps most agents in the notebook. Not because any single piece is impossible, but because nobody puts the pieces together in one coherent guide.
This module puts the pieces together.
The complete journey
M1 → M10: The narrative arc of the guide
Before getting into what makes an agent production-ready, it's worth a moment to look at where you're coming from. This is Module 10 of 10. The end. And the road you traveled matters:
M1: Hand-rolled ReAct loop with the OpenAI API
A while loop, a prompt, parsing tool_calls, manual execution.
Your first agent: ~50 lines of Python, 2 tools, no framework.
→ "This is how an agent works on the inside."
M2: Professional tools
@tool with Pydantic schemas, error handling, external APIs.
→ "An agent without solid tools is a chatbot."
M3: Function calling patterns
Parallel calls, routing, extraction, retry.
→ "Having tools isn't enough — you need patterns to orchestrate them."
M4: State machines with LangGraph
StateGraph, nodes, edges, conditional routing, controlled cycles.
Research Agent v1: your first real graph.
→ "The agent needs explicit flow control, not an infinite loop."
M5: Planning and reflection
Task decomposition, quality gates, targeted re-planning.
Research Agent v2: intelligent planning + reflection.
→ "An agent that doesn't think before acting is an inefficient agent."
M6: Memory systems
Checkpointing, long-term memory, conversation management.
Research Agent v3: the agent remembers across sessions.
→ "An agent without memory repeats mistakes and loses context."
M7: MCP and dynamic tools
Servers, clients, protocol-based tool discovery, ecosystem.
Research Agent v4: unlimited tools via MCP.
→ "Tools shouldn't live inside the agent — they should be discovered."
M8: Multi-agent orchestration
Supervisor, handoffs, subagents, router, coordination.
Research Agent v5: 4 specialized agents working together.
→ "A single agent has limits. A team of agents goes past them."
M9: Testing and evaluation
Unit tests, trajectory evaluation, golden datasets, regression, benchmarks.
Research Agent v6: measurable evidence that it works.
→ "Without tests, every deploy is an act of faith."
M10: Production and alternatives ← HERE
Deployment, scaling, monitoring, cost control, Pydantic AI.
Research Agent v7: production-ready.
→ "It works, it's tested, it's deployed, and I built it."
The progression wasn't accidental
Each module solved a limitation of the one before it. M1: "I don't understand how an agent works." M2: "it has no tools." M3: "it has no patterns." M4: "it has no flow control." M5: "it doesn't think before acting." M6: "it forgets everything." M7: "hardcoded tools." M8: "it works alone." M9: "I don't know if it works." M10: "it only works in my notebook."
M10 solves the last limitation. After this module, there's no pending "yes, but...". The system is built, tested, and deployed. From ~50 lines of Python in M1 (a while loop with the OpenAI API) to a production-ready multi-agent system with planning, reflection, memory, MCP, testing, and deployment. From Level 1 to Level 3, the levels we defined in the very first capsule of Module 1.
What makes an agent production-ready
Production is a mindset, not a checklist
There's a temptation to treat production as "complete these 10 steps and you're done." It doesn't work like that. Production-readiness is a mindset that permeates every design decision: you think about failure modes while writing the code, you think about cost while designing the architecture, you think about scaling from the very first request.
That said, there are concrete dimensions that separate a prototype from a production system:
1. Deployment: an accessible, documented service
A production service has REST endpoints with documentation, health checks any orchestrator can query, async execution that returns immediately and allows polling, and containerization for reproducible deployment. From notebook.ipynb to a FastAPI server with POST /research, GET /status, GET /result, GET /health, OpenAPI docs, and a Docker container.
2. Health: the system knows whether it's healthy
It isn't enough for the service to be "up." It needs to know whether it works: are all 4 agents responding? Are the MCP servers reachable? Are the API keys valid? Does the LLM provider respond in reasonable time? A health check that returns {"status": "ok"} without verifying anything is decoration. One that verifies every critical dependency is infrastructure.
3. Monitoring: continuous visibility
Without monitoring: "is it doing okay?" → "I think so." With monitoring: "error rate 2.3%, avg latency 4.1s, daily cost $34, task completion 87%." Monitoring in production includes: structured logging (not print()), per-request tracing with LangSmith, business metrics, alerts when metrics cross thresholds, and dashboards.
4. Cost: budget under control
Agents are expensive. Multi-agent is 3x more expensive. Without cost control, a user can send 100 queries in a minute, a query can spin into loops consuming thousands of tokens, and you don't know what it costs until the bill arrives. Cost control: token budgets per request, rate limiting per user, model routing (simple queries → cheap model), caching, and cost dashboards with alerts.
5. Resilience: the system recovers from failures
In production, the question isn't if something will fail — it's when. LLM provider down → fall back to an alternative. MCP server down → fall back to local tools. Expired API key → alert + rotation. Badly formed query → the token budget cuts execution short. Agent produces garbage → the quality gate rejects it. Graceful degradation, circuit breakers, retry policies, and per-component fallback strategies.
The preview
Each of these 5 dimensions gets its own capsule:
- Capsule 02: Deployment patterns — FastAPI + LangGraph Platform
- Capsule 03: Scaling and performance — async, caching, pooling
- Capsule 04: Monitoring and observability — LangSmith, alerts, dashboards
- Capsule 05: Error recovery and resilience — degradation, circuit breakers
- Capsule 06: Cost control — token budgets, rate limiting, model routing
- Capsule 07: Pydantic AI comparison — alternatives, with criteria
Prerequisites
From Module 9 (Testing and Evaluation of Agents)
This module deploys the tested system from M9. The transition is direct: "you have evidence it works → now put it in production." You need these to be solid:
- Unit tests for tools and edges: You know every individual component works in isolation. In production, these tests run in CI/CD before every deploy
- Integration tests with trajectory capture: You verify the system end-to-end with a real LLM. In production, these tests are your post-deployment smoke test
- Golden dataset and regression testing: You catch degradations automatically. In production, regression tests run periodically against the deployed system
- Baseline benchmarks: You have reference numbers (task completion rate, latency, cost) to compare production performance against
- LangSmith configured: You already use LangSmith for tracing and evaluation. In production, LangSmith becomes your monitoring and debugging tool
From Module 8 (Multi-Agent Orchestration)
The system you're going to deploy is multi-agent. You need to understand its architecture:
- Supervisor pattern: The central coordinator that decomposes tasks, assigns workers, and aggregates results. In production, the Supervisor is the entry point of your service
- 4 coordinated agents: Supervisor, Researcher, Analyst, Writer — each with its own StateGraph, tools, and context
- Shared vs isolated state: You understand what gets shared and what stays isolated. In production, state management directly affects concurrency
From Module 7 (MCP and Advanced Tool Integration)
MCP servers need deployment too:
- MCP servers and clients: In production, MCP servers run as independent services. Health checks verify their availability
- Multi-server setup: The Researcher connects to web search and a papers DB. The Writer connects to the filesystem. Every server needs to be available for the agent to work
From Module 5 (Multi-Step Reasoning)
Planning and reflection have a direct impact on production cost:
- Intelligent planning: Every planning step is an LLM call. In production, you measure what it costs and optimize
- Reflection with quality gates: Quality gates prevent the agent from producing garbage — they're your first line of quality defense in production
Tools for this module
- Python 3.11+
langchainv1.2+ andlangchain-openailanggraphv1.0+- An OpenAI API key (GPT-4.1 or GPT-4.1-mini)
fastapianduvicornfor the REST server- The
langsmithSDK for production monitoring pydantic-aifor the framework comparisonpython-dotenvfor environment variables
pip install langchain langchain-openai langgraph fastapi uvicorn langsmith pydantic-ai python-dotenv
New dependencies: fastapi and uvicorn for the REST deployment — the most widely used web stack in modern Python. pydantic-ai for the framework comparison in capsule 07. You already have the rest from earlier modules.
Objectives of Module 10
By the end of this module you'll be able to:
- ✅ Deploy agents with FastAPI + LangGraph: Implement REST endpoints (submit, status, result) with async execution, health checks, automatic API documentation, graceful shutdown, and containerization. Know LangGraph Platform as a managed deployment option
- ✅ Implement scaling and performance: Async execution for real concurrency, connection pooling for external APIs, caching strategies for repeated queries, and horizontal scaling patterns for when one server isn't enough
- ✅ Set up monitoring and observability: Structured production logging (not
print()), LangSmith in production with per-request tracing, actionable alerts when error rate or latency cross thresholds, performance dashboards and SLA monitoring - ✅ Implement error recovery and resilience: Graceful degradation when an agent fails, circuit breakers at the component level, retry policies with exponential backoff, dead letter queues for failed requests, fallback strategies (alternative LLM provider, local tools)
- ✅ Set up cost control: Token budgets per request to avoid runaway costs, per-user rate limiting to prevent abuse, cost-based model routing (simple queries → cheap model, complex queries → premium model), aggressive caching, and cost dashboards with alerts
- ✅ Compare LangChain agents with Pydantic AI: Implement the same agent in both frameworks, compare philosophies (abstractions vs type-safety), lines of code, testing experience, performance, and ecosystem support. Leave with framework selection criteria grounded in data
- ✅ Apply a tool-selection framework: Beyond LangChain vs Pydantic AI: when to consider CrewAI, AutoGen, Semantic Kernel. A general decision framework for choosing tools deliberately, not by inertia
- ✅ Complete Research Agent v7 — production deployment: Deploy the multi-agent system as a REST service with health checks, monitoring, cost control, error recovery, and a completed production checklist. The agent works, it's tested, and it's deployed
Module map
| # | Capsule | What you'll learn |
|---|---|---|
| 02 | Deployment Patterns | Deploy agents with FastAPI: REST endpoints for submit, status, and result. Async execution so nothing blocks. Health checks that verify agents, MCP servers, and API keys. API documentation with OpenAPI. Graceful shutdown. Containerization with Docker. LangGraph Platform as the managed alternative |
| 03 | Scaling and Performance | Async execution for real concurrency: multiple requests processed at the same time. Connection pooling for external APIs and MCP servers. Caching strategies: result cache for identical queries, tool result cache. Horizontal scaling: when one server isn't enough and how to add more |
| 04 | Monitoring and Observability | Structured production logging with per-request context. LangSmith in production: tracing every run, continuous evaluation, debugging specific requests. Actionable alerts: error rate > 10%, avg latency > 10s, daily cost > threshold. Performance dashboards and SLA monitoring |
| 05 | Error Recovery and Resilience | Graceful degradation: what to do when an agent fails (reassign, simplify, inform). Circuit breakers: detect failing components and stop calling them for a while. Retry policies with exponential backoff. Dead letter queues for requests that fail repeatedly. Per-component fallback strategies |
| 06 | Cost Control and Rate Limiting | Token budgets per request: at most X tokens per query, cut execution short if exceeded. Per-user rate limiting: at most Y requests per minute. Cost-based model routing: simple queries → GPT-4.1-mini, complex queries → GPT-4.1. Aggressive caching. Cost dashboards with alerts |
| 07 | Pydantic AI Comparison | Implement the same agent in Pydantic AI and in LangChain/LangGraph. Compare philosophy (abstractions vs type-safety), lines of code, testing, performance, ecosystem. A decision framework: when to use each. CrewAI, AutoGen, and Semantic Kernel mentioned with selection criteria |
| 08 | Project: Production Deployment | Research Agent v7 (FINAL): FastAPI server with REST endpoints, async execution, complete health checks, LangSmith production monitoring, rate limiting and token budgets, error recovery with fallbacks, verified production checklist. From notebook to real service |
Learning flow
The module follows a progression of make it accessible → make it scalable → make it observable → make it resilient → make it sustainable → give perspective → integrate everything.
You start with Deployment Patterns (capsule 02) because it's the most immediate step: get your agent out of the notebook and expose it as a service. FastAPI endpoints, async execution, health checks, Docker. By the end you have a working server that accepts requests — the first user who isn't you can use your agent.
Then Scaling and Performance (capsule 03) prepares that server for real traffic. A server that processes one request at a time isn't production — you need concurrency, pooling, and caching. After this capsule, your server handles multiple simultaneous users without degrading.
Monitoring and Observability (capsule 04) gives you the eyes you need to operate the system. You can't read every output of every request. LangSmith in production, structured logging, alerts, dashboards. After this capsule, you know at any moment how your system is doing — with numbers, not intuition.
With Error Recovery (capsule 05) you prepare your system for the inevitable: failures. LLM providers go down, MCP servers disconnect, API keys expire. Graceful degradation, circuit breakers, retry policies. After this capsule, a partial failure doesn't take the whole system down — it recovers, or degrades gracefully.
Cost Control (capsule 06) is where costs go from "I think it's reasonable" to "I know exactly what it costs." Token budgets, rate limiting, model routing, cost dashboards. The most pragmatic capsule in the module — the numbers matter when you pay the API bill every month.
Capsule 07 (Pydantic AI Comparison) changes register. After 9 modules with LangChain/LangGraph, you stop and look at the landscape honestly. You implement the same agent in Pydantic AI. You compare. You evaluate. You come out with selection criteria, not brand loyalty. You also get a decision framework for other alternatives: CrewAI, AutoGen, Semantic Kernel.
Finally, the project (capsule 08) integrates everything into Research Agent v7 — the final version. The same multi-agent system from M8, tested in M9, now deployed as a production service with health checks, monitoring, cost control, and error recovery. It's the closing moment: "it works, it's tested, it's deployed, and I built it."
Connection to the final project
Research Agent v6 (M9) → Research Agent v7 (M10) — FINAL VERSION
The Research Agent from M9 has all the functionality and the evidence that it works:
┌─────────────────────┐
│ SUPERVISOR │
│ - Splits the task │
│ - Assigns workers │
│ - Validates output │
└──────────┬──────────┘
│
┌────────────────────┼─────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ RESEARCHER │ │ ANALYST │ │ WRITER │
│ MCP: web, papers│ │ Tools: analyze │ │ MCP: filesystem │
└─────────────────┘ └─────────────────┘ └─────────────────┘
Testing layer (M9):
✓ 30+ unit tests
✓ Integration tests with trajectories
✓ Golden dataset (20+ queries)
✓ Trajectory evaluation
✓ LangSmith tracing
✓ Baseline benchmarks
Production layer (M10): ← WHAT THIS MODULE ADDS
??? Deployment
??? Scaling
??? Monitoring
??? Resilience
??? Cost control
M10 doesn't change the architecture or the tests — it adds a production layer on top of everything that already exists:
┌──────────────────────────────────────────────────────────────────────┐
│ PRODUCTION LAYER (M10) │
│ │
│ FastAPI Server Rate Limiter Cost Tracker │
│ POST /research Per-user limits Per-query tracking │
│ GET /status, /result Token budgets Per-agent breakdown │
│ GET /health Alerts on thresholds │
│ │
│ ┌────────────────────────────────────────────────────────────────┐ │
│ │ AGENT SYSTEM (M8) + TESTING (M9) │ │
│ │ Supervisor → Researcher + Analyst + Writer │ │
│ │ 30+ unit tests + golden dataset + trajectory eval │ │
│ └────────────────────────────────────────────────────────────────┘ │
│ │
│ Health Checks LangSmith Prod Error Recovery │
│ Agents, MCP, API keys Tracing, alerts Circuit breakers │
│ DB connectivity Dashboards, SLA Fallbacks, retry │
└──────────────────────────────────────────────────────────────────────┘
What changes, concretely
1. From notebook to FastAPI server
app = FastAPI(title="Research Agent API")
@app.post("/research")
async def submit_research(request: ResearchRequest) -> ResearchResponse:
task_id = str(uuid4())
background_tasks.add_task(execute_research, task_id, request)
return ResearchResponse(task_id=task_id, status="accepted")
@app.get("/research/{task_id}/status")
async def get_status(task_id: str) -> StatusResponse: ...
@app.get("/research/{task_id}/result")
async def get_result(task_id: str) -> ResultResponse: ...
@app.get("/health")
async def health_check() -> HealthResponse:
return await check_all_dependencies()
The agent is now a REST service any application can consume — a frontend, a CLI, another service, a cron job. POST /research returns immediately with a task_id; the user polls GET /status until the result is ready.
2. Health checks that verify every dependency
Not a plain {"status": "ok"} — a check that verifies the 4 agents, the 3 MCP servers, the OpenAI API key, and the checkpoint database. It returns "healthy" or "degraded" with detail on which component failed.
3. Cost tracking per query
Every query tracks its cost broken down by agent (supervisor: $0.08, researcher: $0.15, analyst: $0.07, writer: $0.17 = total $0.47), along with the model used and the duration. Dashboards aggregate by day, week, and user.
4. Error recovery with fallbacks
If an agent fails, the supervisor reassigns. Researcher fails → simplified search without MCP. MCP server down → local tools. LLM provider timeout → retry with backoff, then fall back to an alternative provider.
5. The full evolution of the Research Agent
v1 (M4): Basic state machine
→ planning → research → synthesis → END
Tools: [web_search]
Tests: none
v2 (M5): + Intelligent planning + Reflection
→ planning_v2 → research → analysis → reflection → [quality gate]
Tools: [web_search, calculate]
Tests: none
v3 (M6): + Memory (checkpointing + long-term)
→ Same graph + checkpointer + memory store
Tools: [web_search, calculate] (hardcoded)
Tests: none
v4 (M7): + MCP dynamic tools
→ Same graph + MCP clients
Tools: [8+ tools from 3 MCP servers] (dynamic)
Tests: none
v5 (M8): → A SYSTEM of 4 coordinated agents
Supervisor → Researcher + Analyst + Writer
Each agent with its own graph, tools, and context
Tests: none
v6 (M9): → SAME SYSTEM + a complete testing suite
30+ unit tests, integration tests, trajectory evaluation,
golden dataset (20+ queries), LangSmith, regression CI/CD
Tests: ✅ EVIDENCE THAT IT WORKS
v7 (M10): → SAME SYSTEM + production deployment ← FINAL
FastAPI server, health checks, async execution,
monitoring with alerts, cost control, error recovery,
verified production checklist
Tests: ✅ | Production: ✅ DEPLOYED AND MONITORED
Every version adds a layer without breaking the existing ones. v7 is the final version — the Research Agent as a production-ready system.
What this module does NOT cover
- ❌ Kubernetes or advanced container orchestration — Docker and containerization, yes. Kubernetes, Helm charts, service meshes, and multi-cluster orchestration, no. That's platform infrastructure, not application work. This module covers what an AI Engineer needs to deploy; a Platform Engineer covers the rest
- ❌ Frontend or UI — The service exposes a REST API. Building a frontend (React, Next.js, etc.) that consumes that API is out of scope. The focus is the agent's backend, not the user interface
- ❌ Complete CI/CD pipelines — M9 mentioned CI/CD for regression testing. M10 doesn't re-teach GitHub Actions, Jenkins, or deploy pipelines. We mention how to plug the deploy into an existing pipeline, but building the pipeline from scratch is DevOps, not AI Engineering
- ❌ Cloud provider-specific deployment — We don't go deep on AWS Bedrock, Google Vertex AI, or Azure AI Studio. The deployment patterns are provider-agnostic: FastAPI + Docker runs on any cloud. Each provider's specific integrations are vendor documentation, not pedagogical content
- ❌ Enterprise-scale multi-tenant architecture — Per-user rate limiting and basic isolation, yes. Full multi-tenancy with data isolation, per-tenant billing, compliance, and enterprise-grade audit trails, no. That's a management system, not an agent
- ❌ Deep Pydantic AI — Capsule 07 implements the same agent in Pydantic AI and compares. It is not a full Pydantic AI course. If you decide to migrate, the Pydantic AI documentation is your next resource
- ❌ Advanced load and stress testing — We mention the tools (Locust, k6) and explain how to do it. We don't implement a full load testing suite with realistic traffic profiles. That's performance QA work
- ❌ Compliance and advanced security — GDPR, HIPAA, SOC 2, PII detection, compliance audit logs. Basic security best practices, yes (secrets management, input validation), but formal compliance requires legal and security expertise that goes beyond this module
The boundary is clear: M10 = how you take a tested agent to real production, with professional patterns for deployment, monitoring, and cost control, and with industry perspective for choosing frameworks. What stays out is specialized infrastructure, compliance, and deep dives into alternative frameworks.
Evidence of success
By the end of this module, you'll know you succeeded if:
- ✅ You can run
curl http://localhost:8000/healthand see a detailed JSON that verifies every dependency of your system: agents, MCP servers, API keys, checkpoint database - ✅ You can send a
POST /researchrequest with a query, get atask_idback in <100ms, poll withGET /status, and eventually get a complete research report withGET /result - ✅ You can open your LangSmith dashboard and see every production request with full tracing: what each agent did, which tools it used, what it cost, how long it took
- ✅ You have alerts configured that notify you if the error rate climbs above 10%, if average latency exceeds 15 seconds, or if the daily cost passes your threshold
- ✅ You can simulate a failure (disconnect an MCP server, invalidate an API key) and watch your system degrade gracefully instead of crashing: it returns partial results or an informative error, not a stack trace
- ✅ You know exactly what your agent costs per query, broken down by agent, and you have rate limiting and token budgets that prevent abuse
- ✅ You can implement the same basic agent in Pydantic AI and articulate with data (not opinions) when you'd choose LangChain/LangGraph vs Pydantic AI vs another alternative
- ✅ Your Research Agent v7 is deployed, monitored, with costs under control, and with a verified production checklist — it's a production-ready system, not a prototype
Quick self-assessment
Ask yourself these questions after completing the module:
- "If a teammate asks me for access to the Research Agent, can I hand them a URL and API documentation?" → If yes, your deployment works
- "If the service goes down at 3am, do I find out before the user reports it?" → If yes, your monitoring works
- "Can I say exactly what the service will cost at 100 daily queries, within a 20% margin of error?" → If yes, your cost control works
- "If someone asks me 'why did you use LangGraph and not Pydantic AI?', can I answer with data from a real comparison?" → If yes, you have selection criteria
If you answered yes to all four → you completed the guide. Well done. If you answered no to any of them → go back and reinforce the corresponding capsule.
Summary
- The production gap is real: Most agents never leave the notebook — not because they don't work, but because nobody knows how to deploy, scale, monitor, and cost-control them. This module closes that gap
- Deployment is more than an endpoint: FastAPI server with REST endpoints, async execution, health checks, graceful shutdown, containerization. A production service is accessible, documented, and operable
- Scaling for real traffic: Async execution, connection pooling, caching, horizontal scaling. Your agent needs to handle 50 simultaneous users, not just you in a notebook
- Monitoring is continuous visibility: LangSmith in production, structured logging, actionable alerts, dashboards. "Is it doing okay?" gets answered with numbers, not with "I think so"
- Resilience: get ready for failure: Graceful degradation, circuit breakers, retry policies, fallback strategies. The question isn't whether something will fail — it's whether your system recovers when it does
- Cost control as a first-class concern: Token budgets, rate limiting, model routing, caching, cost dashboards. Agents are expensive. Multi-agent is 3x more expensive. Without control, an agent in production can burn your budget in hours
- Pydantic AI as a real alternative: Not as a mention, but as a compared implementation. The same agent in both frameworks, with data to decide. Selection criteria, not brand loyalty
- The full journey M1→M10: From a 50-line hand-rolled ReAct loop to a production-ready multi-agent system with planning, reflection, memory, MCP, testing, and deployment. From Level 1 to Level 3. That's what you built in this guide
- Research Agent v7 (FINAL): Same architecture as v5, same tests as v6. But now deployed as a REST service, with health checks, monitoring, cost control, error recovery, and a verified production checklist. From "it works in my notebook" to "it works for real users"
Resources
- FastAPI Documentation — Official FastAPI documentation. Async endpoints, dependency injection, OpenAPI docs, middleware. The deployment framework of this module
- LangGraph Platform — LangGraph Platform documentation for managed deployment. The alternative to self-hosting with FastAPI
- LangSmith Production Guide — The LangSmith guide for production use. Tracing, monitoring, alerts, and continuous evaluation
- Pydantic AI Documentation — Official Pydantic AI documentation. The alternative framework you compare in capsule 07
- Building Effective Agents — Anthropic — Anthropic's perspective on agents in production. Complements the deployment and reliability patterns here
- Production Best Practices — LangChain — LangChain's guide to productionization: deployment patterns, cost optimization, and observability