How to deploy AI agents to production

Monitor in production
HoneyHive Engineering

Deploy an AI agent by setting limits, guardrails, durable state and human checkpoints first, then tracing, online evals and alerts, and roll out in stages.

To deploy an AI agent to production, put controls around the loop before you put users in front of it: limits on how long it can run, guardrails on what goes in and out, state that survives a restart, a human checkpoint for risky actions, and traces so you can see what it did. Then roll it out in stages and score live traffic, because a passing test suite does not tell you how real inputs behave.

Below, each of those concerns is matched to what the official framework and provider docs say. It assumes you already have a working agent; if not, start with how to build AI agents.

What changes when an agent goes live

Anthropic’s Building effective agents (published Dec 19, 2024; the post now notes that much of the tooling it describes has changed since) names the two production risks directly: “The autonomous nature of agents means higher costs, and the potential for compounding errors.” Its answer is to test in a sandbox, keep guardrails in place, set stopping conditions and let the agent “pause for human feedback at checkpoints or when encountering blockers.”

Each of those becomes a deployment task. The table maps them to documented mechanisms.

Concern What to put in place Documented mechanism
Runaway loops and cost A turn limit max_turns and MaxTurnsExceeded in the OpenAI Agents SDK
Bad inputs and outputs Guardrails Input, output and tool guardrails in the OpenAI Agents SDK
Restarts and long waits Durable state Checkpointers and thread IDs in LangGraph
Risky actions A human checkpoint Pause for feedback, per Anthropic
Not knowing what happened Tracing, online evals, alerts HoneyHive monitoring docs

Set limits before launch

Anthropic advises including “stopping conditions (such as a maximum number of iterations) to maintain control.” In the OpenAI Agents SDK the limit is max_turns, and the run raises MaxTurnsExceeded when it is passed. The running agents docs also say max_turns=None disables the limit, so check that nothing in your config does that.

Hitting a limit should not look like a crash to the user. The same docs describe error handlers for when you “want to return a controlled final output instead of ending the run with the corresponding error.”

Add guardrails where they run

The OpenAI Agents SDK guardrails docs split checks into three kinds, and where each runs matters for deployment:

  • Input guardrails run “on the initial user input” and only for the first agent in the chain. By default they run in parallel with the agent, so the agent can start spending tokens before a tripwire fires. Setting run_in_parallel=False makes the guardrail finish first.
  • Output guardrails check the final answer, only for the agent that produces it, and always run after the agent completes.
  • Tool guardrails wrap function tools and check calls before and after they execute. Handoffs do not use this pipeline.

When a guardrail trips, the runner raises an exception and halts the run, and a rejected final output is not saved to the session. Your service has to catch those exceptions and return something sensible. Anthropic describes the same idea as one model instance handling the query while another screens it. For the concepts, see AI guardrails, and for the attack side see prompt injection.

Keep state somewhere that survives a restart

In-memory state disappears when a container restarts or a request lands on another instance. LangGraph’s persistence docs say checkpointers “persist a thread’s graph state as checkpoints” and list “fault tolerance” and “human-in-the-loop workflows” among their uses. Runs are scoped by a thread ID passed in config. The docs also note that InMemorySaver and MemorySaver keep checkpoints in RAM, so they are lost on restart; the docs say to use a persistent checkpointer such as PostgresSaver for production. See LangGraph.

The OpenAI SDK has a related rule: its running agents docs say “In most applications, pick one persistence strategy per conversation”, and that session persistence cannot be combined with server-managed conversation settings.

Decide where a human steps in

Anthropic says agents can “pause for human feedback at checkpoints or when encountering blockers.” In deployment terms, pick the actions that need approval (the ones you cannot undo), and make sure the agent’s state is saved while it waits, which is where the checkpointer above matters. The patterns are covered in human-in-the-loop AI. If the agent acts with credentials, see AI agent identity.

Roll out in stages

Anthropic recommends “extensive testing in sandboxed environments, along with the appropriate guardrails.” Sandbox first, then a small share of real traffic with the scores below watched, then more. HoneyHive’s trace configuration docs list rollout_percentage, feature_flag and ab_variant as fields you can attach to traces, so each version’s results can be compared.

Watch it after launch

Three layers cover what you can observe once the agent is live:

  • Traces record each step. See agent observability.
  • Online evaluations score live traffic. HoneyHive’s online evaluation docs say evaluators run asynchronously on incoming traces without adding latency to your application, and note that “Python evaluators are much cheaper to run than LLM evaluators.” They suggest full coverage under 1K events a day, roughly 25 to 50% from 1K to 10K, and roughly 5 to 25% above 10K.
  • Alerts tell you when something moves. HoneyHive describes two types: aggregate alerts that “Monitor when metrics cross absolute thresholds” and drift alerts that “Detect when performance degrades compared to previous periods.”

More on what to track is in AI agent monitoring. The checks you ran before launch carry over; see AI agent evaluation.

Production monitoring in HoneyHive

HoneyHive’s monitoring docs describe a dashboard for “cost, latency, token usage, and evaluator scores”, automated evaluations on production traces, and alerts for thresholds or drift. To set it up, send traces from your deployed agent, attach version fields such as prompt_version and environment as described in the trace configuration docs, turn on the online evaluators you need, and create alerts on the metrics you care about.

FAQ

What should an AI agent have before it goes to production?

A turn limit, guardrails on inputs, outputs and tool calls, state that survives a restart, a human checkpoint for risky actions, and tracing. Anthropic recommends "extensive testing in sandboxed environments, along with the appropriate guardrails" (source).

How do I stop an agent from looping forever in production?

Set a maximum number of iterations. Anthropic advises including "stopping conditions (such as a maximum number of iterations) to maintain control", and the OpenAI Agents SDK raises MaxTurnsExceeded when a run passes max_turns.

Can I evaluate every production trace?

Code-based evaluators are cheap enough to run on all traces. LLM judges cost model usage, so sample them. HoneyHive's online evaluation docs suggest roughly 5 to 25% above 10K events a day.

Share