█
LastWrite
  • > Curriculum
  • > Pricing
  • > For Educators
  • > About
  • > Contact
Log InGet Started

Questions, concerns, bug reports, or suggestions? We read every message, write to us at [email protected].

More ways to reach us →
LastWrite

Structured computer science lessons for aspiring developers and security professionals.

[email protected]

(201) 785-7951

Mon–Fri, 9 AM–5 PM EST

Learn

  • Curriculum
  • Pricing

Company

  • About
  • For Educators & Schools
  • Contact Us

Legal

  • Terms of Service
  • Privacy Policy
© 2026 LastWrite. All rights reserved.
Curriculum/AI Agents/Code-First Agents/Code-First Agent Capstone: Build and Deploy a Production Agent
120 minAdvanced

Code-First Agent Capstone: Build and Deploy a Production Agent

After this lesson, you will be able to: Design, build, evaluate, and deploy a production-grade AI agent, with observability, error handling, cost tracking, and a public interface.

Code-first capstone. Production-grade is the bar. This is the lesson where everything you've learned across this track lands in one shipped artifact. By the end you have a deployed agent, an evaluation harness, observability, and a Loom demo.

Prerequisites:Model Context Protocol (MCP): Connect Agents to External Tools

Pick your problem (production bar)

  1. 1

    1. Same rule: real, yours.

  2. 2

    2. Bar is highest yet. Production = it can be used by someone other than you, and it survives a week without your intervention.

  3. 3

    3. Stack hint: LangGraph for orchestration, raw SDK for hot paths, MCP for tools, FastAPI for the surface.

Architecture

  1. 1

    1. Sketch the graph: nodes, state, conditional edges, end conditions.

  2. 2

    2. Identify external tools. Wrap as MCP server (one) or LangChain tools (each).

  3. 3

    3. Decide retrieval: do you need RAG? If so, pick a vector store and chunking strategy.

  4. 4

    4. Decide deployment: FastAPI + Docker → Railway/Fly. Add a /chat endpoint and a static page client.

  5. 5

    5. Decide observability: LangSmith or your own logging to Postgres.

Minimal FastAPI surface for an agent

Wrap a LangGraph app behind an HTTP endpoint.

python
from fastapi import FastAPI
from pydantic import BaseModel
# from your_graph import app as agent_app
app = FastAPI()
class ChatRequest(BaseModel):
session_id: str
message: str
@app.post('/chat')
async def chat(req: ChatRequest):
# config = {'configurable': {'thread_id': req.session_id}}
# result = await agent_app.ainvoke({'message': req.message}, config=config)
# return {'response': result['response']}
return {'response': 'TODO: wire up your graph here'}

💡 Evaluation, not just demos

Build 20 test queries with expected answers. Run them on every commit. Score: factually correct (yes/no), has citations (yes/no), token cost (number), latency (ms). Track metrics over time. THIS is what 'production-grade' means.

Cost and observability

Cost, log token counts per call to a Sheet or DB. Sum daily. Set a kill-switch if a session exceeds $X. Observability, every conversation logged with input, output, tool calls, errors, and latency. LangSmith ($39/mo) is the easy button; a Postgres table works for free.

Deploy and demo

  1. 1

    1. Dockerize. Test locally with `docker build && docker run -p 8000:8000`.

  2. 2

    2. Deploy to Railway or Fly.io. Point a domain or use the auto-domain.

  3. 3

    3. Build a tiny static frontend (one HTML file with a chat box) that hits /chat.

  4. 4

    4. Run the eval suite against the deployed instance.

  5. 5

    5. Record a 5-min Loom: problem → architecture → live demo → eval results → cost numbers. Submit.

Sign in and purchase access to unlock this lesson.

Sign in to purchase
←Multi-Agent Systems: Orchestration, Supervisor Patterns, and When Not To
Back to Code-First Agents
Passion Project: Research / Security / Code-Review Agent→