LangGraph monitoring in production: find the odd run, then block the call
LangGraph monitoring that finds the run your dashboards miss. Send LangGraph traces to Amiril, see why a run stood out, then block that tool call before it runs.
LangGraph monitoring that finds the run your dashboards miss. Send LangGraph traces to Amiril, see why a run stood out, then block that tool call before it runs.
Most LangGraph monitoring is a dashboard of run counts, error rates, latency and token use, with an alert when one of them crosses a line. When a support agent refunds the same order twice, both refund calls succeed and come back quickly, so that dashboard shows one more successful run. We build Amiril, which ranks each run against the agent's history and points to the step that stood out. From there you write a rule that stops that tool call before it runs, and the rule reaches the running agent without a redeploy. The example agent here is a made-up support agent built with LangChain's create_agent, and the run is one where it refunded an order twice.
The agent is called support, and it has two tools, lookup_order and issue_refund. A customer writes in about a damaged parcel, order A-1042, $84.50. The agent looks the order up and calls issue_refund. The payment provider answers {"status": "pending"}, which is what it says about any refund it hasn't settled yet. The model reads "pending" as a failure and calls issue_refund again with the same order and the same amount. That one comes back refunded. Then the agent tells the customer the money will be back on their card by 12 December.
Both calls returned normally, and the extra step added about a second and a few hundred tokens, less than this agent's runs already vary by. Unless the customer mentions the second $84.50, or somebody in finance matches refunds against orders at the end of the month, nobody hears about it.
Most LangGraph monitoring today starts with LangChain's own product, LangSmith. You set LANGSMITH_TRACING=true and an API key, plus LANGSMITH_AGENT_ID and LANGSMITH_AGENT_ENVIRONMENT to say which agent and environment the traces belong to, and each run of the graph arrives as a trace. LangSmith's LangGraph guide has the setup. The trace of this run would show both refund calls in order, with their arguments and results.
The monitoring sits on top of those traces. Each agent environment gets a prebuilt dashboard, and in its section for the five most-called tools the double refund adds one call to issue_refund. Alerts watch measures such as error count and average latency over a 5 or 15 minute window, and one run with no error and an extra second won't trip either of them.
The closest LangSmith comes to catching the double refund is an online evaluator, where an LLM judge reads each trace that matches a filter and writes a feedback score you can alert on. That works once someone has thought to ask the judge whether any order was refunded twice. Amiril compares each run with the agent's own earlier runs, and a second refund call stands out because this agent almost never makes one. LangSmith's Tool Gateway can block a tool call, but only for tools on MCP servers, so it can't reach a tool defined in your own graph like issue_refund. That gap, and how LangSmith Engine's issues differ from Amiril's, are what we cover in LangSmith vs Amiril.
For LangGraph monitoring in Amiril, the traces come in over OpenTelemetry, with OpenInference's LangChain instrumentation doing the recording. It runs beside LangSmith's tracer: leave LANGSMITH_TRACING set and each run goes to both.
pip install openinference-instrumentation-langchain opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
These lines run once at startup, before the graph handles its first request:
from openinference.instrumentation.langchain import LangChainInstrumentor from opentelemetry import trace from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor provider = TracerProvider() provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter())) trace.set_tracer_provider(provider) LangChainInstrumentor().instrument(tracer_provider=provider)
The exporter reads the standard OpenTelemetry variables. Both values come from the Data page in Amiril, under Set up a new installation:
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="<OpenTelemetry traces endpoint>" export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf" export OTEL_EXPORTER_OTLP_TRACES_HEADERS="Authorization=Bearer <your API key>"
Amiril files each run under the agent's name. With create_agent that's the name you pass to it. With a StateGraph you built yourself it's the name you pass to compile. TypeScript uses OpenInference's @arizeai package in the same way, and the LangGraph traces guide has both languages.
Amiril learns what is normal for each agent from that agent's own earlier runs in the same environment. When the double-refund run arrives it is ranked against them. Its rarity shows as Top 1%, with the bits behind it when you hover, and the run page lists the rarity factors that put it there, one sentence each:
issue_refund was called more than once, which happened in 3 of 640 other runs calling it
On the Events tab, Next rarity factor jumps to the second issue_refund call, with the first call's "pending" result just above it.
Once a run's rarity reaches the bar your review budget sets for that agent, the run is marked Anomaly and waits on the Anomalies page. You can confirm an issue from the run right away, and if nobody does, a rarity issue forms anyway once two more runs share its strongest rarity factor. The Issues page has one row per problem, with its run count, its severity and a write-up by an AI investigator that reads a sample of the runs.
The made-up date is caught another way. Every run gets a grounding check, which looks for any date, time or number the agent stated that no tool result or earlier message contains. "12 December" fails it, and a failed grounding check opens a Critical issue on the spot. With Slack connected, your channel gets a message as soon as an issue forms at High or above, and a daily digest of issues that came back or are rising. The same thing happens to a payments agent that times out, retries and pays an invoice twice, the case we use on the agent observability page.
Running LangGraph in production means the model will meet "pending" again, because the provider sends it for every unsettled refund. An issue's page carries a rule suggestion when Amiril can draft a rule that would have stopped the issue's runs, and the draft has already been tested on past runs. Some rarity factors carry Turn into a rule as well. Both open the rule editor, and for this run the rule allows one refund per order:
@id("one-refund-per-order")
@sentence("This order was already refunded in this conversation")
@per("order_id")
block (
agent == "support",
tool == "issue_refund"
)
when {
issue_refund{}
};With @per("order_id"), the pattern issue_refund{} matches only earlier refunds for the same order, and it looks through every run in the session. On LangGraph the session is the thread_id in the graph's config. So a customer who comes back to the same thread an hour later asking whether the refund went through can't set off another one, and a refund for a different order still runs. @per and the other annotations are in the rule language reference.
Test on past calls replays any version of the rule, an unpublished draft included, over the last 24 hours, 7 days or 30 days of traced calls, and lists each call it would have fired on. If your agents sometimes split a refund in two on purpose, or retry one the provider really rejected, those calls turn up in that list and you change the rule before it touches anyone. A published rule starts in Shadow, which records what it would have done and lets every call through.
Blocking happens inside the agent's process, through the SDK. It reports what each rule decided, and the OpenInference setup above goes on sending the traces. On LangGraph the SDK is middleware for create_agent:
pip install "amiril[langgraph]"
import amiril
import amiril.langgraph
from langchain.agents import create_agent
amiril.init()
agent = create_agent(
model,
[lookup_order, issue_refund],
middleware=[amiril.langgraph.middleware()],
name="support",
)
amiril.instrument(agent)amiril.init() reads AMIRIL_API_KEY and AMIRIL_ENDPOINT from the environment, and instrument checks that Amiril's middleware is first in the list. Switch the rule to Enforce and the next duplicate refund comes back to the model as this, in place of the tool's result:
The call to issue_refund was not performed. Rule one-refund-per-order blocked it: This order was already refunded in this conversation (issue_refund.exists true). Do not retry this call with different arguments or achieve the same outcome another way; tell the user it was not performed.
The SDK checks each call against a copy of your published rules held in the agent's process and refreshed about once a minute. A check makes no network request of its own, and changing the rule later needs no redeploy. If Amiril can't be reached, the SDK keeps enforcing the last rules it had. On a StateGraph you built by hand in Python, Amiril's ToolNode takes the place of LangGraph's, the setup LangGraph tool call guardrails walks through next to LangChain's own middleware.
Connect a trace source to send your LangGraph runs to Amiril.