LangSmith Deployment: running agents in production
- Advanced
- 40 min
- Lesson 6 of 7 in LangChain ecosystem
- Last verified
Select text in the lesson first to keep it with your note. With the keyboard, move focus here and press the button: the note goes with the section you are reading.
In this module
On this page
Before you start
- Completed:LangSmith: tracing, datasets and evaluation
- Completed:Cost and latency optimizationProduction: cost, serving and observability
You will be able to
- Explain why agent workloads need more than a request handler, and define assistant, thread, run, store and checkpoint in an agent server.
- Choose between managed cloud, hybrid, self-hosted, a standalone server and building your own, and state the trade-off of each.
- Pick a double-texting strategy for a given product and state what it costs.
- Design authentication, thread ownership, identity injection, budgets and a kill switch for a deployed agent.
- Plan a release that keeps paused runs resumable, gated by evaluation, with runbooks for the failures that will happen.
The job is ready to leave testing and go live. Ananya stands at the desk with a checklist.
A second customer request arrives before the first has been answered. Someone has to decide whether to hold it, restart the first, or run both at once.
Someone also holds the keys, and someone pays the cloud bill. Who owns the line, the keys and the bill?
Concept
In the story, going live is production, and the system that runs it is LangSmith Deployment, a hosted and self-hostable runtime for agents. The docs describe it as a workflow orchestration runtime built for agent workloads. Its server, the Agent Server, is the same runtime in every hosting option. You write the graph; the server supplies the plumbing that agents need and ordinary web handlers lack.
This lesson covers what that plumbing is, the choices you make when you deploy (where it runs, how it treats a second message, who is allowed in, what a run may spend) and how to ship changes without stranding runs. It is the last stop in the LangChain chain, and most of its content is operations. The principles repeat what you saw in cost and latency: measure, budget, and decide what happens when something fails.
Why It Matters
Getting a graph to work on a laptop is the first twenty percent. An agent run can last seconds or hours, stream partial results, pause for a person, and be started on a schedule. It runs many times at once, for many users, each with their own data. A plain request-and-response handler fights all of it: connections time out, a deploy kills runs in flight, there is no way to resume, and every team re-invents a queue. A server built for agents moves that into the runtime. It does not make the agent safe, cheap or correct. That part is still yours.
Mental Model
The live system has a server that takes jobs and hands them to workers through a queue. A database records every job and every state copy. A scheduler (cron) starts jobs on its own. Each worker-and-job pairing has a number. At the door stand authentication, which checks who you are, and authorisation, which checks that you may read this job’s record.
Nothing in the server stops an agent doing something unwise with its tools. That is the agent’s job description, which you wrote.
What the Agent Server provides
From the Agent Server overview (read 2026-10-21):
| Concept | Meaning |
|---|---|
| Assistant | A graph plus its configuration: an agent set up for a task. One graph can back many assistants, for example one per tenant or persona |
| Thread | The container for one conversation’s state; checkpoints live here |
| Run | One execution of an assistant, on a thread or without one |
| Cron job | A scheduled run |
| Store | Long-term memory across threads; kept in PostgreSQL by default and replaceable |
| Checkpoints | Snapshots written during a run so an interrupted run can resume |
| Task queue | Handles signalling, cancellation and streaming. The docs say Redis holds only ephemeral data here, while run data lives in PostgreSQL |
Core resources (assistants, threads, runs, cron jobs) are always stored in PostgreSQL. A client can open a streaming connection, and the server forwards events over server-sent events. Checkpoint durability follows the same modes you met in lesson 4: the overview names async (the default) and exit.
A run can also be started and left. The background-run guide shows creating a thread, creating a run (the call returns before the work finishes), checking its status later (it reports pending, then success), joining to wait for the end, and reading the final state. This is the shape for work that outlasts an HTTP request.
# Illustrative, after the background-run guide.
thread = await client.threads.create()
run = await client.runs.create(thread["thread_id"], "support",
input={"messages": [{"role": "user", "content": "Where is order 8841?"}]})
await client.runs.join(thread["thread_id"], run["run_id"]) # or poll runs.get
state = await client.threads.get_state(thread["thread_id"])A deployment project is small. The configuration file names the dependencies and maps graph names to the code that builds them, and may name an environment file. A graph is exported already compiled; the docs recommend that over a factory function. Because the server provides persistence, you do not attach your own checkpointer to the graph you deploy.
{
"dependencies": ["."],
"graphs": { "support": "./src/agent/graph.py:graph" },
"env": ".env"
}Where it runs
The deployments page lists four types, and a fifth option is to build your own.
| Option | Who runs what | Pick when |
|---|---|---|
| Cloud (managed) | LangChain runs the whole deployment, on AWS and GCP. Needs a paid plan tier | You want the fastest route and an external processor is acceptable |
| Hybrid | LangChain runs the control plane; you run the servers and data in your infrastructure | Data must stay in your network but you want the managed console |
| Self-hosted with control plane | You run the control plane and servers in your Kubernetes cluster, with self-hosted LangSmith. Enterprise plan | Regulated or isolated environments, full control |
| Standalone server | You run the server with containers and supply PostgreSQL, Redis and a licence; no control plane | Smallest footprint, you operate it |
| Build your own | A web framework, a job queue or workflow engine, and a Postgres checkpointer | You already have a platform. You re-implement streaming, resume, queues, cron and concurrency rules |
Decision factors: where data may live, how many people can operate it, scale, how the cost is metered against what your own infrastructure would cost, and lock-in. A useful framing for the lock-in question: the graph code is open source and portable; the server is the part you rent. The docs also say deployments are framework-agnostic and can host other frameworks’ agents, which matters if your team does not use one stack.
A second message arrives: double texting
A user sends another message while the agent is still working. The docs name four strategies, with enqueue as the default, and note that this is a feature of the deployment product and not the open-source library.
| Strategy | What happens | Cost |
|---|---|---|
| Enqueue | The current run finishes; the new input waits and runs next | The user waits; a stale first answer still appears |
| Reject | New runs are refused while one is active | The user is turned away |
| Interrupt | The current run halts with its progress kept, the new input is added, and execution continues from that state | The graph must cope with half-finished work, such as a tool call that started and did not finish |
| Rollback | The run halts and all progress is reverted, including its input; the new input starts a fresh run | The earlier work is discarded |
Choose by product. A chat assistant usually wants interrupt or rollback: the user has changed their mind, so the old run is worthless, and making them wait is worse. A form-filling or transactional agent that has already taken a real action wants enqueue or reject, because a half-done action must not be abandoned silently. In every case, decide on purpose; the default is a decision somebody else made.
Security and budgets
Authentication is part of the server. Custom authentication runs on every request: it validates credentials and returns the user’s identity (and any extra fields such as role or organisation). By default, LangSmith’s hosted deployments use LangSmith API keys in a header, which you can replace with your own handler. The auth page states that a self-hosted server has no default authentication: you implement the whole model.
Authorisation handlers run after that, at global, resource or action level, with the most specific match winning. For thread ownership, set an owner in the thread’s metadata when it is created, and filter reads and searches so each user sees only their own threads. Runs inherit their thread’s access control. Store access works by rewriting the namespace instead of filtering. Skip this and a user who obtains another’s thread id can read or resume it, which is an insecure direct object reference.
Four more rules for a deployed agent:
- Identity reaches tools from the authenticated context, never from model output. The auth page says application code reads the user from the run configuration. This is the same injection rule from lessons 1 and 2.
- Budgets per run. Model calls, tool calls, wall-clock time, tokens and money. Set the graph’s recursion limit yourself, as lesson 3 says.
- A kill switch and a degraded mode. The ability to cancel runs or to disable write tools (answer-only mode) while you investigate.
- Make tools safe to repeat. The platform does not make your tools idempotent or your data safe.
Keep secrets in a secret store, not in state or traces; redact before tracing as lesson 5 describes; and write the deletion path before launch. Data may live in threads, checkpoints, the store and traces, and a deletion request must reach all of them.
Performance and cost
Tokens usually dominate the bill. Route and classify with a cheaper model, summarise or trim history, trim large tool outputs, and keep the stable part of the prompt at the front so provider caching can help (see the cost lesson). Run independent branches in parallel and stream for perceived speed. Track cost per successful task, not cost per call, along with the 95th-percentile latency per step, the loop rate and the tool error rate. Capacity planning: scale workers on queue depth; size database connections; remember checkpoint writes grow with steps times state size, so a few large blobs in state become a database problem. Prune old checkpoints.
An example of diagnosis: Postgres CPU is at 90 percent after launch and the checkpoint table grows by 5 GB a day. Likely causes: large objects in state written at every step, no retention policy, a durability setting that writes more often than needed, loops running more steps than designed. First checks: the checkpoint size by thread, steps per run, and whether documents are in state when ids would do. Fixes: store references, shrink state, set retention, and cap steps.
Releasing without stranding runs
A deploy while runs are paused is the question that finds weak designs. If 2,000 runs wait for approval and you ship a new graph, what must be true for them to resume?
- Their state is in the durable store, not in the process, so a restart does not lose it.
- The new graph can read the old state. Version the state’s shape, handle missing keys, and avoid renaming or removing keys that live runs use.
- Node names and the order of interrupts in a node are stable, or you provide a migration. Resume values match by position, and a resumed run re-enters its saved node.
- Side effects are idempotent, because a node can re-run.
- Workers drain in-flight runs, or the platform’s rollout behaviour is understood and tested.
Gate every change to a prompt, model or graph with the offline experiment from lesson 5, then release gradually with online evaluators watching. Pin versions of langchain, langgraph, langsmith and provider packages in a lock file. Upgrade on a branch with evaluations and a comparison of traces. Keep the legacy bridge package only as long as the migration takes. The versioning policy says breaking changes arrive in major releases and deprecated APIs are removed later, but provider packages and product features move on their own schedule.
Runbooks for the failures that will occur:
| Failure | First response |
|---|---|
| A model provider is down | Fall back to the second model; degrade to answer-only if needed |
| A runaway loop | Cancel the run through the kill switch; check the budget and recursion limit |
| A corrupted thread | Repair the state with an update call, or fork from the last good checkpoint |
| A queue backlog | Shed or limit by tenant, scale workers |
| A bad release | Roll back graph and prompt together; keep the previous version deployable |
Tools for the job: a decision guide
| Situation | Choice |
|---|---|
| One prompt, one typed answer | The provider SDK, or structured output on a model |
| A tool-using assistant with a standard loop | create_agent |
| Approvals, resume, custom branching, dynamic parallel work | A LangGraph graph |
| A long task with planning, files and subagents | Deep Agents |
| A hosted durable runtime with streaming, scheduling and many assistants | LangSmith Deployment |
| A workflow engine is already the company standard | That engine calling model steps, with LangSmith for tracing |
| Observability only | LangSmith tracing, with or without LangChain |
Real-World Application
A bank wants a support agent. Data must stay in the country, and every approval must be auditable. The reasoning: the hosting model that keeps the data plane in the bank’s own network (hybrid or self-hosted) fits the residency rule, and which of the two depends on whether the bank can accept an external control plane. Identity comes from the bank’s single sign-on through a custom auth handler; threads are owned by the authenticated customer. Refunds and transfers sit behind an interrupt that records the approver, the time and the payload shown. Money-moving tools take an idempotency key. Tracing redacts account numbers before data leaves. Each run has a model-call budget and a recursion limit, and a kill switch disables write tools. A change reaches production only after the evaluation gate, and it ships to a small share first.
Interview Perspective
Expect: “Take a working local LangGraph agent to production for 50,000 daily users. What changes?”, “Users double-send messages. What do you do?”, “A deploy happens while 2,000 runs are paused for approval. What has to be true for them to resume?”, “Choose hosting for a bank.”, “Why not wrap graph.invoke in a web endpoint?”
A strong answer to the first: a durable checkpointer and a server runtime; authentication and thread ownership; identity injected into tools; budgets and a kill switch; idempotent tools; streaming and background runs; tracing with a redaction policy; an evaluation-gated pipeline with gradual release; a capacity plan; runbooks.
Common mistakes: treating the agent as an ordinary request handler; shipping with local in-memory persistence; no thread-ownership check; never choosing a double-texting behaviour; unbounded cost per run; changes with no evaluation gate or rollback; full prompts with personal data in traces; assuming a managed platform makes tools safe.
Provenance: Common industry pattern. These are the questions this topic tends to draw for agent roles; none is verified for a named company.
Practice Questions
- Basic: Define assistant, thread and run, and map them to your application’s concepts.
- Intermediate: Users send a second message while the agent works. Choose a strategy for a chat product and for a form-filling agent.
- Advanced: Postgres CPU is at 90 percent after launch and checkpoints grow by 5 GB a day. Diagnose and fix.
- Product-Company: Choose hosting for a bank whose data must stay in the country and whose approvals are audited for seven years. Defend the choice and the audit design.
Activity
For an agent you know, fill in one line for each: hosting model, double-texting strategy, how a user proves who they are, who may open a thread, the run budget, the kill switch, and the evaluation gate.
Homework
Write a one-page production readiness review for a support agent. Include the architecture in words or a sketch, the answers to the seven activity lines, three runbooks, a deploy plan that keeps paused runs resumable, and the metrics you would watch in the first week.
Quick Revision
- Agent runs are long, bursty, stateful and interruptible; a request handler fights that.
- Assistant: graph plus config. Thread: state container. Run: one execution. Store: memory across threads. Checkpoints: resumable snapshots. Queue: Redis for signals; data in PostgreSQL.
- Hosting: cloud, hybrid, self-hosted with control plane, standalone, or build your own.
- Double texting: enqueue (default), reject, interrupt, rollback. Choose by what a half-done run costs.
- Auth on every request; thread ownership by metadata filter; identity injected into tools; self-hosted has no default auth.
- Budgets, a kill switch, idempotent tools, redacted traces, a deletion path.
- Paused runs survive a deploy only if state is durable and compatible. Gate releases with evaluation.
Check yourself
- Walk-through: Take a local agent to production for 50,000 daily users and list what changes.
- Variation: Repeat it for a bank with data-residency rules.
- Common misconception: “Deployment is wrapping
graph.invokein an endpoint.” That loses resume, streaming, queues, scheduling and concurrency rules.
Related
Resources & Further Reading
Checked sources to go deeper. The essential ones come first in each group.
Official documentation
Observability concepts (LangSmith documentation) (opens in a new tab)
The tracing vocabulary (run, trace, thread) that the monitoring and runbook slides rely on, from the previous lesson's area.
Use time-travel (LangGraph documentation) (opens in a new tab)
How to replay or fork from an earlier checkpoint, which is the mechanism behind the corrupted-thread runbook line.
Further reading
Idempotent requests (opens in a new tab)
A concrete, widely used design for idempotency keys, which makes tools safe to repeat after a resume or retry.
OWASP Top 10 for Agentic Applications for 2026 (opens in a new tab)
A published list of the most critical risks for agentic systems, to check a deployment's access control, budgets and stop mechanisms against.
More for this module: LangChain ecosystem resources
Practice
Test what you just read. Quizzes and cards are grouped by module: LangChain ecosystem.
Check yourself13 questions on what this lesson set out to teach
Checking answers needs JavaScript. You can still read every question and option below.
Keyboard: arrow keys move between options. Space or Enter selects the focused option.