All guides
Updated By Kartik Sarangmath

How to Deploy an AI Agent to Production in 2026

What changes when an agent serves real users, and what we saw when we crashed one

In production, an agent serves other people, runs for hours, waits on approvals, spends money, and gets killed by deploys while nobody is watching. We crashed one on purpose to see what survives.

The Short Version

If you needDo this
Agents in production without building the rest of this table yourselfUse Omnara: sessions, machines, approvals, and crash recovery included, on any model, hosted or on your own servers
Agents that survive restarts and deploysKeep the session log outside the process, and resume from it
Many usersCheck ownership on every session, file, credential, and tool, and run untrusted code in a sandbox
Approvals that can wait for daysSave the paused run and the exact pending tool call, and let only one worker resume it
To bound spendingSet limits per run and per user, and treat provider spend caps as a backstop
To know what an agent didTrace every model and tool call
A Claude-only or OpenAI-only prototype, with that lab running the agent and storing its transcriptsClaude Managed Agents or OpenAI's Agents API

What Happened When We Crashed an Agent

We ran the Claude Agent SDK in Docker with Claude Sonnet 5.5. The agent had two tools: one that sends an email to a customer and logs it, and one that waits on a slow report job. We told it to send one email, wait for the report, and finish. Then we killed the container at different points, started a new one, and told the agent to continue.

When the container diedTranscript kept?What the agent did after the restartEmails sent
While waiting for the report, after the emailYesRe-ran only the interrupted wait, then finished1
Mid-send, after the email went out but before the result was savedYesSaid it couldn't tell whether the email went out and stopped to ask a person1
While waiting for the report, after the emailNoResume failed with "No conversation found," so the job started over2

In the mid-send case, the resumed agent recognized that the outcome was uncertain and asked a person. Without the transcript, our job started over and sent the email again.

Saving the transcript took more than one folder. Claude Code keeps sessions in ~/.claude, but its config lives in ~/.claude.json, outside that folder. Mount both, or set CLAUDE_CONFIG_DIR to a volume so Claude Code keeps everything under it.

The hard case is a crash between doing something and recording it. In our run, the agent stopped and asked, but the job still needed a person. Give tools that change things an idempotency key that the receiving service checks, or a way to check whether the action already happened, so the agent can continue on its own.

We ran each case once, on one model and version.

Sessions That Survive Restarts

The agent's state has to live outside the process running it. There are a few ways to do that:

  • A durable execution engine, like Temporal or the Workflow SDK, records each step so a run resumes after a crash. You still build the API, sandboxes, and approvals around it.
  • A checkpointer in your own database. LangGraph's in-memory checkpointer loses everything on restart, so production setups use the Postgres checkpointer. It doesn't clean up old checkpoints, so plan for that.
  • The harness's own session store. The Claude Agent SDK can mirror transcripts to S3, Redis, or Postgres, but the mirror is best-effort and doesn't cover files on the machine.
  • A managed agent platform. Claude Managed Agents and OpenAI's Agents API keep the session log for you, on their own servers. Omnara saves each finished step to Postgres, so if a worker dies, another worker continues from the last saved step.

Resuming usually runs some code again. LangGraph restarts the interrupted node from the beginning, so anything before the pause has to be safe to repeat.

Sandboxes and Isolation

Run untrusted code in a sandbox, usually one per session. You can keep the agent loop in your backend and have it run code through sandbox tools, which is how Vercel's Open Agents template works. The Claude Agent SDK also supports running the whole loop inside a container.

Permission prompts don't contain what the agent runs, so put a container or microVM around anything it executes, limit where it can connect to, and keep credentials out of it. Stripe's coding agents run on dev machines that are cut off from production and the internet, so they run without approval prompts at all. On GitHub-hosted runners, GitHub's agent runs behind a firewall and can only push to its own branch.

Cold starts matter once people are waiting. Ramp keeps a pool of warm sandboxes and starts one as soon as a user begins typing.

Many Users: Identity and Credentials

When an agent acts for a user, it needs that user's access, not yours. On their managed agent platforms, Claude and OpenAI can keep each user's credentials in a vault and inject them outside the sandbox, so the agent only sees a placeholder. That injection doesn't work with self-hosted sandboxes yet.

On Omnara, custom tools run in your own backend, so customer credentials can stay in your systems. MCP server credentials are used from its workers, never from the agent's machines. In other setups, tokens reach your tool code or the runtime directly, so check where credentials become readable before running untrusted code.

On AWS and Azure, AgentCore Identity and some Foundry tools can run the OAuth sign-in and store tokens for you. Your app still has to connect each sign-in to the right user.

None of this checks who owns what. AgentCore, for example, doesn't enforce which user a session belongs to, and leaves that mapping to your backend. Whatever platform you use:

  • Take the tenant from the authenticated request, not from anything the client sends.
  • Check ownership when someone starts, reads, streams, resumes, or approves a run.
  • Test that one tenant can't reach another tenant's sessions, files, memory, or credentials.
  • Set concurrency and spending limits per tenant.

Memory needs the same care. Check which memory stores each user can attach to a session, and mount shared reference material read-only. A prompt injection can write to memory the agent can change, and later sessions read it as trusted.

Approvals That Can Wait for Days

Use a pause that outlives the process, like LangGraph interrupts or the Claude Agent SDK's defer decision from a PreToolUse hook. Then someone can approve hours later and a different process can resume the run. defer only works when Claude makes one tool call in that turn, and Claude Code deletes saved sessions after 30 days by default.

If you use a managed agent platform, check how it handles this. In Omnara, a tool set to ask first pauses the agent on that exact call until someone approves or denies it. The pause is saved in Postgres and holds no worker, so it survives restarts and deploys however long the person takes.

If you build it yourself, save these alongside each pending approval:

  • The run state at the pause, in durable storage
  • The exact pending call, with its tool name and arguments, so the reviewer approves what will run
  • Who decided, what they decided, and when
  • An approval record that only one worker can claim, plus a stable action ID the tool uses to reject a duplicate
  • The version of your code, since a run paused on Monday may resume into Friday's deploy

Don't rely on notifications to find pending approvals. Claude Managed Agents drops a webhook after three failed deliveries, so keep a list you can poll. When a reviewer says no, record it and enforce it in the tool, then tell the model so it can pick another approach.

Cost Limits

Set explicit limits on model turns, tool retries, and elapsed time for every agent. Framework defaults range from a handful of turns to none, they change between versions, and a framework "step" isn't always a model call. Test your limits on the version you deploy. Stripe lets its coding agents fix CI failures once and then stop, because more rounds rarely help.

Provider spend caps lag behind usage. OpenAI says its spend limits aren't instantaneous, Gemini's billing data can lag behind its project caps, and calls already running can push past any cap. Claude Managed Agents has a per-session dollar cap that stops a session between model calls. Stop accepting new work before a budget runs out.

One startup was charged $82,314 in 48 hours after a Gemini key was stolen. Keep keys on the server, restrict them to the APIs they need, and alert when the cost per finished task goes up.

Tracing

Trace every model call and tool call, with the user, the agent version, and the cost attached. The OpenTelemetry conventions for AI are still in development, and the defaults differ.

The Claude Agent SDK's telemetry leaves out conversation content unless you opt in, though its local transcripts still keep it. The AI SDK records inputs and outputs by default once telemetry is on, and the OpenAI Agents SDK sends traces to OpenAI by default. Set what gets recorded and where it goes on purpose, especially if users' data passes through.

Ways to Deploy

The first decision is whether you adopt a platform that brings its own agent loop, or deploy an agent you already built and build the rest around it.

Use a managed agent platform

A managed agent platform brings the agent loop, session log, machines, and approvals behind an API. You configure the agent instead of writing the loop, which removes most of the work in this guide. I compared these platforms in more detail in Claude Managed Agents alternatives.

Omnara is the strongest choice for production. It runs any model on your own keys, either on Omnara Cloud with no platform fee or self-hosted on your own servers. Slack, Discord, GitHub, schedules, and webhooks are built in. You can also change a running agent through the API without a redeploy.

It keeps the agent loop on its own workers. Agents run commands on sandboxes from providers like E2B, Daytona, and Modal, or on your own computers through a daemon that only makes outbound connections.

Omnara's recovery code is public. Its failure handling docs link the tests that cover crash recovery, interrupted tool calls, and machine failures, so you can check that behavior yourself. Claude Managed Agents and OpenAI's Agents API run on proprietary backends, so you rely on their documentation for how they recover.

Claude Managed Agents and OpenAI's Agents API limit you to one lab's models. They suit a prototype on an account you already have.

Even with a platform, check who maps your users to their credentials, what happens when a webhook is missed, and where the transcripts are stored. Cloud Agent APIs Compared goes through how each API handles users, credentials, and webhooks.

Self-host a framework agent

Run your agent on a framework with a durable layer under it:

Some of these include authentication or sandbox integrations, but you still configure them and check the access rules and spending limits for your app.

Self-host a harness

Run a harness like the Claude Agent SDK or Codex on your own machines. Anthropic's hosting guide is clear that this isn't like hosting a normal API. Each active session runs its own CLI process, and its transcript stays in local files unless you add a session store.

You can give each session its own container or run several in one, depending on what those processes can reach. Everything from the crash test applies here. If you use Pi, Pi Durable saves its sessions as they happen, on Cloudflare, Vercel, or your own servers.

Host your agent on a platform

If you already build on LangChain, Google Cloud, or AWS, LangSmith Deployment, Google's Agent Runtime, and AWS AgentCore can host an agent you built with a framework. They run it and scale it on their cloud. The agent's logic and the approval, credential, and ownership checks stay yours.

If You Build It Yourself

This is the architecture I'd start with. Ramp and Stripe describe similar setups.

  1. An API that authenticates users, starts runs, and streams progress, with a way to reconnect to a stream.
  2. A durable run layer, either a workflow engine or a job queue in your database, with step and spend limits per run.
  3. A session log outside the worker, holding events, checkpoints, and pending approvals.
  4. A sandbox per session for anything the agent executes, with limited network access.
  5. Credentials kept out of the sandbox, injected at a proxy or in your tool code.
  6. Tracing from the first day, with the user and version on every run.

For a small team, deploy an authenticated API and one worker, with Postgres as both the session log and the job queue. Save each job before you return its run ID, and store checkpoints outside the worker. Add a hosted sandbox provider if the agent runs code.

Before launch, test a worker crash, a stream reconnect, a duplicate tool call, and recovery after a deploy. Keep a small set of real tasks with checks you wrote yourself, and run them before changing the model, prompt, tools, or harness.

Which Way to Deploy

Choose Omnara. It's the only open-source managed agent platform among these options, and it already runs most of the build-it-yourself architecture above for you. That includes an authenticated API with streams that resume, a session log in Postgres, stateless workers, and machines with no inbound ports.

After a crash or deploy, another worker continues the agent without rerunning a tool on its own, and approvals wait as long as a person takes. One deployment serves many customers, and your app enforces each customer's budget with the usage and cancellation APIs.

There's no lock-in. You can export all your data at any time, including every agent's full history, and run it on your own self-hosted Omnara by emailing [email protected].

FAQ

How do I deploy an AI agent to production so it survives restarts and can wait for human approval?

Keep the agent's state outside the process, and save each pending approval with the run so any server can resume it. The least work is Omnara, which continues a crashed agent on another worker without rerunning tools and holds an approval for as long as a person takes.

Claude Managed Agents and OpenAI's Agents API keep sessions and pending approvals for you, on one lab's models. Building it yourself means a durable engine like Temporal around your loop, or LangGraph's Postgres checkpointer, plus the API, approval flow, and sandbox around it. Either way, kill the agent mid-task before launch and check what runs twice.

How do I make an AI agent survive restarts?

Store the agent's state outside the process and resume from it. The simplest route is a managed agent platform like Omnara, which saves every step to Postgres and continues the agent on another worker. You can also put a durable execution engine like Temporal around your own loop, or save checkpoints in your database with something like LangGraph's Postgres checkpointer. Whichever you choose, kill it mid-task before launch and check what runs twice.

How do I deploy a LangGraph agent without LangSmith?

You can deploy the open-source LangGraph library on its own, behind your own API and worker with the Postgres checkpointer. Paused approvals resume from the saved checkpoint, so check that the caller owns a thread before resuming it. Add a job that deletes old checkpoints. LangChain's ready-made server, LangSmith Deployment, needs an Enterprise plan to self-host.

How do I run the Claude Agent SDK in production?

Keep each session's transcript and config on a volume or in a session store, put the sessions in containers with limited network access, and keep credentials out of them. Set your own turn, retry, and spend limits. Use the defer decision if approvals can take longer than the process stays up.

How do AI agents wait for human approval?

The platform saves the paused run, including the exact tool call waiting for approval, and resumes it when someone decides. In Omnara, the agent pauses on the tool call until someone approves or denies it in the API, the dashboard, or Slack, even after restarts and deploys. If you build it yourself, the run can resume in a different process days later as long as the saved state, the pending call, and your code version are all still there.

How do I stop an agent from running up a huge bill?

Set limits on turns, retries, and time for every run, and a budget per user if users can start agents. Use provider spend caps as a backstop, since they lag. Keep API keys on the server and restricted to the APIs they need.

What are my options for a self-hosted AI agent platform?

Omnara is the strongest option. It's open source under Apache 2.0, so you can self-host the whole platform, including its agent loop, approvals, and API. Agent history then lives in your own Postgres, with files and memory in storage you run.

If you have a LangGraph agent and want LangChain's server for it, LangSmith's self-hosted deployment needs an Enterprise license. Self-Hosted Managed Agents covers more options, including OpenHands and Coder, and what Claude, OpenAI, and AWS let you run on your own machines.