AgentStat

Live telemetry for LLM agents in React, token rate, status and health on one canvas, with alerts for stalls, runaway output and status thrashing.

01 -Overview
AgentStat is a React component that shows what each agent is doing right now: its token rate, its status and a health score, with a marker the moment something goes wrong, an agent that stops producing while it still claims to be working, output that runs away, a status that flips back and forth.

It works from the events your agents already emit. Forward stream chunks and tool calls, or plug in an adapter for the Vercel AI SDK, LangChain, OpenTelemetry or AG-UI, and AgentStat derives the rest. The only dependency is React, and the chart ships in about 23 KB.

02 -Features

It reads the stream you already have. Early versions asked you to compute token rates yourself and hand them over. Now you forward raw events, a chunk of tokens, a tool call starting or ending, a finish, and AgentStat derives the rate, time to first token, inter-token latency and status. An agent waiting on a tool reads as waiting, not stalled.

Alerts measured against a holdout. Anomaly detection only earns trust if it stays quiet when nothing is wrong. So the detectors are scored against labelled scenarios, including a holdout written by a reviewer who never saw the tuning. The rebuild took that holdout from 63 false alarms per agent-hour to 4, and a fresh event-driven holdout since caught 10 of 10 real problems at 2.2. It isn't perfect, long tool calls reported as active can still trip it, and the docs say so.

A health score that won't pretend. The score is built only from signals you actually provide. Telemetry can't detect hallucinations, so hallucination risk stays empty unless you report a confidence score. It never invents one to fill the gap.

Lines that can't lie. Earlier versions drew Catmull-Rom splines, which looked smooth and occasionally drew peaks that never happened. Curves are now monotone cubics, so a line never leaves the range of the samples it connects, and long windows are downsampled keeping every column's minimum and maximum, so a one-sample spike can't vanish.

Or skip the chart. useAgentTelemetry runs the same event handling and detectors without a canvas, with a status badge, anomaly banner, roster and timeline built on it, also as shadcn/ui source to copy and restyle. The table under the demo below is one of them.

Live Demo

No agents are shown. Use the arrow keys to inspect samples and Space to pause.

No anomalies · watching for stalls, spikes and thrash
Agents in the demo
AgentStatusRateTokensHealth
The component itself, v0.6.0, fed by a scripted event stream. The Coder goes quiet while still marked active; about ten seconds later the stall detector flags it.
03 -Integrations

Each adapter is its own entry point with no dependencies, safe to run on the server. You only ship the ones you import.

@dan-build/agentstatThe chart and event streams22.6 KB
/ai-sdkVercel AI SDK v5–v7, useChat and streamText1.4 KB
/langchainLangChain.js and LangGraph.js, one line per sub-agent2.3 KB
/otelOpenTelemetry GenAI spans, as a span processor2.2 KB
/ag-uiAG-UI protocol events0.5 KB
/sseServer to browser, with replay and reconnect2.2 KB

Sizes are min+gzip, bundled the way an app ships them. Everything in the main entry, components included, is 25.5 KB.

04 -Architecture

In 0.5 the 2,100-line component became three parts, each tested on its own. Every one is a choice to do less in React, and more directly.

L01

Event Streams

Events go into a stream that keeps the last five minutes. A chart that mounts late replays them at their original times, several charts can share one stream, and over Server-Sent Events a dropped connection resumes where it stopped. Agents appear as their first events arrive, so there's no roster to keep in sync.

createAgentStream()
L02

Framework-free Store

Agents, samples and detectors live in a plain store outside React. Samples sit in typed-array ring buffers, 16 bytes each, and the legend and panel read the store's snapshots through useSyncExternalStore. The samples themselves never pass through React state.

useSyncExternalStore
L03

Canvas Renderer

One requestAnimationFrame loop draws every agent, apart from the React tree. At 50 agents, 15-minute windows and 20 updates a second, the slowest frame went from about 200 ms to under 15 ms, and memory from 170 MB to 50 MB. Snapshot tests check the canvas output call for call.

M4 downsampling
05 -Note

I built AgentStat because watching agents run in the dark felt wrong. Telemetry shouldn't require heavy dashboards or complex state machines.

This is a quiet tool. It doesn't shout. It just draws a line, scores the health, and gets out of the way. If you're building agentic workflows, you already know the chaos. This is the calm.

— Built with monotone cubics and too much coffee.

The visualization of autonomous intelligence requires more than data, it requires a clarity of intent. AgentStat remains the silent observer within the machine.

$npm install @dan-build/agentstat
DS2026 · v0.7.0 · MIT