How to monitor a long-running AI agent
Monitor a long-running agent by tracing every step, grouping the steps into one session, and scoring the outcome against the user's goal. A run can return success on every step and still fail the task.
By Arun Prasad · Published · Last updated
On this page
Why long-running agent monitoring matters
A run with many steps has more places to go wrong, and standard monitoring only shows that requests went through, not whether the answer was right.
Here is a hypothetical case. An agent works through a task across dozens of steps. Every tool call returns a 200 and no span shows an error. The user still never gets what they came for, perhaps because the agent drifted away from the original request partway through. A dashboard built on request status shows green.
Teams that run agents for a long time tend to hit two kinds of problems, and they are different. One is a runtime problem: state growing large or checkpointing becoming expensive for long threads is a known pattern in multi-step agent systems. That is a problem with how the agent runs. This guide covers the other: seeing what a long run did and whether it worked.
Step 1: Decide what a finished run means
Define success as the user's goal being met, not as the last span returning without error. Write the goal down for each agent task before you instrument anything.
A goal can be short: "the refund was issued" or "the user got an answer from the knowledge base." Writing it down gives you something to score against later. PRISM tracks the outcome against the user's goal, not just span status.
Step 2: Send every step of the run to your tracing tool
Pick the SDK, OpenTelemetry or HTTP route that fits your stack. Agent steps appear in PRISM when your integration sends them.
PRISM's Agent Runs view shows steps, tool calls, retries, handoffs and state. You can send steps via a framework adapter, OpenTelemetry, the Python SDK, the HTTP API, or a voice integration. The full list is in the PRISM integrations page:
- Framework adapters: LangChain (PRISMtraceCallbackHandler), LangGraph (wrap_langgraph), LiteLLM, Google ADK (PRISMtraceADKAdapter, labeled Beta in the SDK) and the OpenAI Agents SDK (labeled Preview in the SDK).
- OpenTelemetry: OTLP trace export over http/protobuf or http/json. gRPC is not served.
- Custom: the PRISM Python SDK or the HTTP API.
The SDK is Python only. If your agent is written in TypeScript, Go or Java, use the HTTP endpoint or OpenTelemetry.
Step 3: Group the steps into one session
Set a session_id before your first production run, grouping cannot be added to old traces later.
In PRISM, traces that share a session_id form one conversation. Sessions cannot be backfilled. For OpenTelemetry, PRISM groups turns only from attributes you declare (gen_ai.conversation.id, session.id or prismtrace.session_id). It does not infer sessions, so a run with none of these attributes shows up as unconnected traces.
If you use LangGraph or Google ADK, PRISM can read the framework's own conversation ID (thread_id or session_id). That needs SDK version 0.5.0 or later.
Step 4: Score the outcome, not just the steps
Use deterministic rules, which run on every session, plus an LLM judge if your plan allows.
- Deterministic rules give the same verdict for the same input. They use no model and run on 100% of sessions, with no sampling.
- LLM-as-judge has a model read the exchange. It scores every incoming trace until your plan's daily allowance is reached (100 a day on Free). After that, only the deterministic rules run.
Each verdict links to the rule, the span, the source checked and the reason, so you can see why a run was marked as failed. Core scores are on the Free plan. Custom evaluators and the Evaluators Hub need Builder or above. See the PRISM evaluators page for a full breakdown of rule types and plan gating.
Step 5: Watch for drift and repeated failures
Look at sessions for drift over many turns, and at failure patterns across runs, to see whether one cause is hitting many runs.
The Sessions view shows a multi-turn journey and where it drifts. PRISM also groups repeated failures into patterns and shows how many sessions share each one. A pattern shared by many sessions is usually a better place to start than a single bad run. Agent Intelligence adds patterns across runs: user intent, how conversations feel, repeated failures and missing knowledge. Agent Observability and Agent Intelligence are both on the Free plan. More on the views is on the PRISM product page.
How this looks in production
PRISM records each exchange as a trace with its request, response, model, cost, timing and scores. Traces that share a session ID are shown as one conversation. Where most monitoring tools show whether each step returned success, PRISM also scores whether the multi-step outcome matched the user's goal, so a run where every tool call returned 200 but the task was never completed shows up as a failure, not a pass. This is what a call that sends one exchange looks like.
Example:
curl -X POST https://api.prism.blockconvey.com/api/traces \
-H "X-PRISMtrace-Key: pt-sk-<your-key>" \
-H "Content-Type: application/json" \
-d '{
"project_id": "<your-project-id>",
"model": "<model-name>",
"input_messages": [{"role": "user", "content": "<what the user asked>"}],
"output_message": "<the model reply>",
"latency_ms": 420
}'The auth header is X-PRISMtrace-Key; a Bearer token is rejected. Keys look like pt-sk-... and are shown once. The call sends one exchange per request, and the five fields above are required. This example leaves out the session field.
Some limits to plan around:
- Each ingest endpoint accepts 2,000 requests per minute. POST /api/traces allows more on higher plans: 3,000 a minute on Growth, 5,000 on Scale and 10,000 on Enterprise.
- Data is kept for your plan's retention period: 14 days on Free, 90 on Builder, 180 on Growth and 365 on Scale. Full plan details are on the pricing page.
Common mistakes
Four mistakes show up most often. Each has a fix.
- Treating a 200, or a finished last span, as success. The tool can return 200 and the task can still fail. Fix: write down the user's goal (Step 1) and score the outcome against it.
- Not setting a session ID. Sessions can't be backfilled, so steps sent without one never join up. Fix: set the session ID, or declare one of the supported OpenTelemetry attributes, before the first production run.
- Assuming the LLM judge keeps scoring past your plan's allowance. After the daily allowance runs out, only the deterministic rules run. Fix: check your daily allowance, and rely on deterministic rules for anything that must be checked every time. For a full breakdown of what each plan includes, see the PRISM evaluators page.
- Sending content-free traces and expecting judge scores. Content-free ingest drops prompt text, response text and error messages from storage, and those traces get no LLM-judge scores (they are not billed for scoring either). Fix: use content-free ingest only where you don't need LLM-judge scores.
Send your first agent run to PRISM
See the steps, session and scores your integration sends for one real run.
Free to start, 100 credits each month.