How do you monitor agents in production?hard
You have to trace the full execution path — plan, tool call, observation, updated plan, next tool call, final answer — not just the final response, since agents take real actions and can fail in ways a single LLM call never would.
Step monitoring tracks each step's goal, reasoning summary if available, selected action, tool called, input/output, and resulting state, which is what lets you reconstruct why the agent made a decision after the fact. Tool monitoring is critical because tool calls interact with external systems — track tool name, arguments, output, latency, errors, retries, rate limits, and permission failures; a repeated identical search call is a clear loop signal, not just noise. Loop and no-progress detection watches for repeated tool calls, repeated arguments, repeated observations, or hitting the max-step limit with no new information gained — the runtime should stop the loop and either return the best available answer or escalate rather than burn budget indefinitely. Goal completion monitoring tracks task success, partial success, failure, and the reason for failure — a task like "book a meeting" only succeeds if a calendar event was actually created with the right attendees and time, not just because the agent produced text that sounds like it handled it. Safety and permission monitoring is non-negotiable for agents with real capabilities: track attempted restricted actions, blocked tool calls, human approval requests, and sensitive data access, since high-risk actions like sending email, deleting a file, transferring money, deploying code, or updating a database should often require human approval before execution. Cost and latency monitoring matters more for agents than single-call systems because agents multiply LLM calls and tool calls — track number of LLM/tool calls, tokens per step, total tokens, cost per task, total runtime, and the slowest step, since that's usually where optimization effort should go. Finally, validate the final answer before returning it: did the agent actually answer the original question, complete all required steps, reflect tool results accurately, and avoid unsupported claims — for structured outputs validate the schema, and for tool actions validate the resulting state rather than trusting the agent's own narration of what happened.