By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Up to now the compiled graph has been a Python object in a lesson. Production adds everything around that object: a process that builds it once, an HTTP boundary that authenticates callers and supplies a thread_id, a durable store for checkpoints, limits that stop a runaway run, and the traces and dashboards that tell you what happened. The graph code does not change at the boundary; what changes is who owns the run.
There are two common shapes. A graph server — LangGraph's Agent Server, started locally by the CLI and deployed as a service in production — treats graphs, threads, interrupts, streaming and checkpoints as first-class endpoints. Your own FastAPI service embeds the compiled graph as a library and keeps full control of the API's shape, auth and response format. Choose by how much of the run lifecycle you want to own; the observability duties are identical either way.
InMemorySaver loses every paused approval when the process restarts.__interrupt__ is in the result, respond with the payload and a resume route; a pending human decision is a normal state, not a 500.Command(resume=...) on the same thread.The snippet below is the boundary in miniature: compile once, keep the thread id in the config, probe the checkpointer for readiness, and return the interrupt payload instead of an error. build_graph is the factory from the project lessons; the authorization check stands in for your ownership model.
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from langgraph.types import Command
from support_graph import build_graph # the factory from the project lessons
class RunRequest(BaseModel):
thread_id: str
message: str
class ResumeRequest(BaseModel):
thread_id: str
decision: str
# Compile once at startup; the database saver's migrations run before traffic.
graph = build_graph()
app = FastAPI()
def final_text(state: dict) -> str:
messages = state.get("messages") or []
return messages[-1].text if messages else ""
@app.get("/healthz")
def healthz() -> dict:
"""Liveness: is the process up?"""
return {"status": "ok"}
@app.get("/readyz")
async def readyz() -> dict:
"""Readiness: can this process reach the checkpoint store?"""
try:
await graph.aget_state({"configurable": {"thread_id": "readiness-probe"}})
except Exception as exc:
raise HTTPException(status_code=503, detail="checkpoint store unreachable") from exc
return {"status": "ready"}
@app.post("/runs")
async def start_run(request: RunRequest) -> dict:
# authorize(request.thread_id, current_user) before touching state
config = {"configurable": {"thread_id": request.thread_id}}
result = await graph.ainvoke(
{"messages": [{"role": "user", "content": request.message}]},
config,
)
return {"answer": final_text(result), "interrupted": "__interrupt__" in result}
@app.post("/runs/{thread_id}/resume")
async def resume_run(thread_id: str, request: ResumeRequest) -> dict:
if thread_id != request.thread_id:
raise HTTPException(status_code=400, detail="thread id mismatch")
# authorize(thread_id, current_user) and validate request.decision
config = {"configurable": {"thread_id": thread_id}}
result = await graph.ainvoke(Command(resume=request.decision), config)
return {"answer": final_text(result), "interrupted": "__interrupt__" in result}Tracing answers what actually ran. With LangSmith enabled, every graph run becomes a tree of nodes, tool calls and model calls with inputs, outputs, latency and token counts, so a slow or wrong answer can be traced to a node instead of guessed at. Set LANGSMITH_TRACING=true, a LANGSMITH_API_KEY and a project name in the deployed environment; keep the key in your secret manager, not in the image.
Traces are for engineers and are not a permanent record. The checkpoint store is the runtime's source of truth for resuming a thread, and your structured logs are the durable record a reviewer will read. Keep the three separate and use each for the question it answers.
| Signal | Where to look | Why it matters |
|---|---|---|
| A run is slow | LangSmith trace: node durations | Find the node, not the whole request |
| A refund is stuck | Checkpoint store: pending interrupts by age | An approval queue is a queue; it needs an expiry policy |
| Retries spike | Structured logs: attempts per tool | Either the dependency is down or the policy is too wide |
| Quality regressed | Evaluation set pass rate | Prompt or model drift shows up as a score before a complaint |
| A run cannot resume | Readiness health, checkpoint store | The pause lives in the store; no store, no resume |
Before the graph serves real customers, every line below should have a named owner and a way to verify it.
langgraph and langchain-core pinned in the lockfile./healthz and /readyz are wired to the checkpointer, and alerts cover error rate, p95 latency and interrupt age.Key takeaways
A compiled graph is a library object; production adds a process that builds it once, an authenticated HTTP boundary and a durable checkpoint store.
One graph per process, one authorised thread_id per conversation, and a database checkpointer — never a client-supplied thread id.
Return a pause as data: an __interrupt__ payload and a resume endpoint are normal responses, not errors.
Observe at three levels: LangSmith traces for what ran, the checkpoint store for what is paused, and structured logs for the durable record.
Ship with limits, health checks, evaluation and rollback — and a way to find every pending approval from a dashboard.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.