LangSmith Deployment: running agents in production

  • Advanced
  • 40 min
  • Lesson 6 of 7 in LangChain ecosystem
  • Last verified

Open slides(34 slides)

Before you start

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.

Diagram: Requests pass authentication and authorisation, then the server hands runs to workers through a queue.

stream events (server-sent events)

Client

Authentication and authorisation
who are you, may you read this thread?

Agent Server

Cron scheduler

Task queue (Redis, ephemeral signalling)

Workers run the graph

PostgreSQL
assistants, threads, runs, checkpoints, store

Diagram summary: Requests pass authentication and authorisation, then the server hands runs to workers through a queue. Workers write every run and checkpoint to PostgreSQL, and a scheduler can start runs on its own. Events stream back to the client as they happen. Nothing here limits what the agent’s own tools may do.

What the Agent Server provides

From the Agent Server overview (read 2026-10-21):

ConceptMeaning
AssistantA graph plus its configuration: an agent set up for a task. One graph can back many assistants, for example one per tenant or persona
ThreadThe container for one conversation’s state; checkpoints live here
RunOne execution of an assistant, on a thread or without one
Cron jobA scheduled run
StoreLong-term memory across threads; kept in PostgreSQL by default and replaceable
CheckpointsSnapshots written during a run so an interrupted run can resume
Task queueHandles 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.

Diagram: One graph can back many assistants, each a graph plus configuration.

Graph (your code)

Assistant: graph plus configuration

Assistant per tenant or persona

Thread: one conversation's state
(checkpoints live here)

Run: one execution

Cron job: scheduled run

Store: long-term memory
across threads

Diagram summary: One graph can back many assistants, each a graph plus configuration. An assistant’s conversations are threads that hold checkpoints, and each execution is a run on a thread. Cron jobs start scheduled runs, and the store holds long-term memory shared across threads.

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.

Python

# 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"])
Diagram: A background run returns before the work finishes.
Agent ServerClientAgent ServerClientthe run continues in a workercreate threadthread idcreate run on that threadreturns at once (status: pending)join (or poll the run status)successget thread statefinal state
Diagram summary: A background run returns before the work finishes. The client creates a thread and a run, gets control back immediately, then joins or polls until the run succeeds, and finally reads the final state. This is the shape for work that outlasts an HTTP request.

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.

JSON

{
  "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.

OptionWho runs whatPick when
Cloud (managed)LangChain runs the whole deployment, on AWS and GCP. Needs a paid plan tierYou want the fastest route and an external processor is acceptable
HybridLangChain runs the control plane; you run the servers and data in your infrastructureData must stay in your network but you want the managed console
Self-hosted with control planeYou run the control plane and servers in your Kubernetes cluster, with self-hosted LangSmith. Enterprise planRegulated or isolated environments, full control
Standalone serverYou run the server with containers and supply PostgreSQL, Redis and a licence; no control planeSmallest footprint, you operate it
Build your ownA web framework, a job queue or workflow engine, and a Postgres checkpointerYou 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.

StrategyWhat happensCost
EnqueueThe current run finishes; the new input waits and runs nextThe user waits; a stale first answer still appears
RejectNew runs are refused while one is activeThe user is turned away
InterruptThe current run halts with its progress kept, the new input is added, and execution continues from that stateThe graph must cope with half-finished work, such as a tool call that started and did not finish
RollbackThe run halts and all progress is reverted, including its input; the new input starts a fresh runThe 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.

Diagram: The right strategy depends on the product.

no: the old run is now worthless

yes: a half-done action must not be dropped

Second message arrives while a run is active

Has the active run taken a real action?

Chat assistant: interrupt or rollback

Transactional agent: enqueue or reject

Diagram summary: The right strategy depends on the product. A chat assistant whose first run is now worthless should interrupt or roll back. An agent that has already taken a real action should enqueue or reject, because a half-done action must never be abandoned silently.

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.

Diagram: Every request is authenticated, then authorised, and thread reads are filtered by the owner recorded in the thread’s metadata when it was...

yes

no

Request with credentials

Authentication handler:
validate, return user identity

Authorisation handler:
global, resource or action level

Thread owner in metadata
equals this user?

Read or resume the thread

Denied

Diagram summary: Every request is authenticated, then authorised, and thread reads are filtered by the owner recorded in the thread’s metadata when it was created. Without the owner check, anyone who obtains another user’s thread id can read or resume it.

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.

Diagram: Before shipping a new graph while runs are paused, five things must hold in order: state lives in the durable store, the new graph can read...

Deploy a new graph while
2,000 runs wait for approval

State in the durable store,
not the process?

New graph can read the old state?

Node names and interrupt order stable?

Side effects idempotent?

Workers drain in-flight runs?

Paused runs resume safely

Diagram summary: Before shipping a new graph while runs are paused, five things must hold in order: state lives in the durable store, the new graph can read old state, node names and interrupt order are stable, side effects are idempotent, and in-flight runs drain. If any is false, paused runs can be stranded.

Runbooks for the failures that will occur:

FailureFirst response
A model provider is downFall back to the second model; degrade to answer-only if needed
A runaway loopCancel the run through the kill switch; check the budget and recursion limit
A corrupted threadRepair the state with an update call, or fork from the last good checkpoint
A queue backlogShed or limit by tenant, scale workers
A bad releaseRoll back graph and prompt together; keep the previous version deployable

Tools for the job: a decision guide

Diagram: Pick the smallest piece that does the job: the SDK for a single prompt, create_agent for a standard loop, LangGraph for approvals and...

One prompt, one typed answer

Tool-using assistant, standard loop

Approvals, resume, custom branching

Long task with planning, files, subagents

Hosted durable runtime, streaming, cron

Only visibility

What do you need?

Provider SDK or structured output

create_agent

LangGraph graph

Deep Agents

LangSmith Deployment

LangSmith tracing

Diagram summary: Pick the smallest piece that does the job: the SDK for a single prompt, create_agent for a standard loop, LangGraph for approvals and custom branching, Deep Agents for long planning tasks, LangSmith Deployment for a hosted durable runtime, and LangSmith tracing when you only need visibility.
SituationChoice
One prompt, one typed answerThe provider SDK, or structured output on a model
A tool-using assistant with a standard loopcreate_agent
Approvals, resume, custom branching, dynamic parallel workA LangGraph graph
A long task with planning, files and subagentsDeep Agents
A hosted durable runtime with streaming, scheduling and many assistantsLangSmith Deployment
A workflow engine is already the company standardThat engine calling model steps, with LangSmith for tracing
Observability onlyLangSmith 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.invoke in an endpoint.” That loses resume, streaming, queues, scheduling and concurrency rules.

Resources & Further Reading

Checked sources to go deeper. The essential ones come first in each group.

Official documentation

Further reading

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.

0 of 13 answered

Keyboard: arrow keys move between options. Space or Enter selects the focused option.

ObjectiveExplain why agent workloads need more than a request handler, and define assistant, thread, run, store and checkpoint in an agent server.

  1. Question 1 of 13A team plans to wrap graph.invoke in an ordinary web endpoint and call it production. Which problem is most likely to hit them first?

    Choose one answer.

  2. Question 2 of 13One graph needs to behave differently for each of three tenants, with different prompts and settings. How does the server model this?

    Choose one answer.

  3. Question 3 of 13In the server's task queue, which statement about Redis and PostgreSQL is correct?

    Choose one answer.

ObjectiveChoose between managed cloud, hybrid, self-hosted, a standalone server and building your own, and state the trade-off of each.

  1. Question 4 of 13A hospital needs agent data to stay inside its own network but wants LangChain to run the management console. Which option fits?

    Choose one answer.

  2. Question 5 of 13What do you have to rebuild yourself if you skip the agent server and assemble your own from a web framework and a job queue?

    Choose one answer.

  3. Question 6 of 13A founder says, "Hosting on the vendor's platform locks us in completely." What is the most accurate response?

    Choose one answer.

ObjectivePick a double-texting strategy for a given product and state what it costs.

  1. Question 7 of 13A chat assistant user types a correction while the agent is still answering the first message. Which strategy usually fits best?

    Choose one answer.

  2. Question 8 of 13A form-filling agent has just submitted a payment when the user sends another message. Which strategy is the riskiest?

    Choose one answer.

ObjectiveDesign authentication, thread ownership, identity injection, budgets and a kill switch for a deployed agent.

  1. Question 9 of 13A self-hosted Agent Server is deployed with no authentication configured. What is the situation?

    Choose one answer.

  2. Question 10 of 13How does a deployment make sure users see only their own threads?

    Choose one answer.

  3. Question 11 of 13Which items belong on the production checklist for budgets and safe operation? Select all that apply.

    Choose all that apply.

ObjectivePlan a release that keeps paused runs resumable, gated by evaluation, with runbooks for the failures that will happen.

  1. Question 12 of 13A release ships while thousands of runs are paused for approval. Which condition is essential for them to resume safely?

    Choose one answer.

  2. Question 13 of 13A team changes a prompt and wants to ship quickly. Which release practice is the most defensible?

    Choose one answer.