AgentWatch

io.github.nicofains1由 GitHub 账号 nicofains1 发布v0.3.1更新于 Oct 25, 2026

Multi-agent observability: cascade failure detection, heartbeats, and forensic replay

已验证STDIO仅桌面安全与监控AI 与机器学习

概览

AI 生成的概览

AgentWatch 是一个本地 MCP 服务器,让助手查看多智能体集群:心跳、跨智能体追踪、级联故障根因、告警与回放。

可以做什么
读取集群健康状况与仪表盘,包括文本仪表盘、各智能体健康状态、近期失败与活跃告警,并可解决告警、为智能体上报心跳。创建追踪 ID 并记录跨智能体关联的追踪事件,再读取某条追踪的事件。从失败事件回溯到根因,并回放一条追踪内的所有级联链。所有数据保存在本地 SQLite 文件中。
适用场景
适用于运行多智能体系统(CrewAI、AutoGen、LangGraph、PocketFlow 或自研框架)并希望助手判断哪个智能体引发了故障级联、查看集群健康或在事故后复盘追踪的场景。
运行要求
通过 npx 作为本地 stdio 进程运行,需要 Node.js 18 或更高版本。npm 包 @nicofains1/agentwatch 使用 better-sqlite3 原生绑定。环境变量 AGENTWATCH_DB 指定 SQLite 数据库路径,默认是当前目录下的 agentwatch.db。未声明认证。
安装前请注意
该服务器会写入本地 SQLite 数据库:上报心跳、记录追踪事件、创建与解决告警都会改动已存数据。请将 AGENTWATCH_DB 指向预期的文件,因为默认文件会创建在当前目录。项目自称处于早期阶段。可选的 OpenTelemetry 导出会把追踪发送到兼容 OTEL 的后端,属于第三方。

安装

在 SourceWeft 中

  1. 打开 控制台中的 AgentWatch,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

agentwatch

Your agent swarm crashed at 2am. You have logs from 10 agents and no idea which one started the cascade. AgentWatch tells you.

It tracks heartbeats, links actions across agents, walks backward from any failure to the root cause, and replays the full sequence. Works with any agent framework (CrewAI, AutoGen, LangGraph, PocketFlow, custom). Stores everything in a local SQLite file.

Early stage. Issues and feedback welcome: https://github.com/nicofains1/agentwatch/issues


See it in action

No install needed:

bash
npx @nicofains1/agentwatch demo

This seeds a 5-agent fleet, triggers a cascade failure, and shows you the full trace:

AgentWatch Fleet Dashboard============================================================Agents: 5 total | 3 healthy | 1 degraded | 1 error | 0 offline
Cascade Failure (4 steps, root cause: scheduler/dispatch-batch)============================================================[ROOT] scheduler/dispatch-batch [ok] 15ms       {"assigned_to": "fetcher"}       |[  1 ] fetcher/call-api [error] 30000ms       TIMEOUT after 30000ms       |[  2 ] processor/transform [error] 120ms       Error: input is null - expected array from fetcher       |[FAIL] notifier/send-alert [error] 8ms       Error: no processed data to report

Install

bash
npm install @nicofains1/agentwatch

Requires Node 18+. Uses better-sqlite3 (native bindings, no external database needed).


Quick start

typescript
import { AgentWatch } from '@nicofains1/agentwatch';
const aw = new AgentWatch(); // creates agentwatch.db in the current directory
// Report heartbeats from your agentsaw.report('agent-a', 'healthy');aw.report('agent-b', 'healthy');
// Trace an action in agent-aconst traceId = aw.createTraceId();const e1 = aw.trace(traceId, 'agent-a', 'fetch-data',  'url=https://api.example.com', 'rows=150');
// Trace a dependent action in agent-b that failsconst e2 = aw.trace(traceId, 'agent-b', 'process',  JSON.stringify({ rows: 150 }), 'Error: out of memory', {    parentEventId: e1.id,    status: 'error',    durationMs: 4200,  });
// Walk back to the root causeconst chain = aw.correlate(e2.id);console.log(chain?.root_cause);// -> { agent: 'agent-a', action: 'fetch-data', ... }
// Print fleet statusconsole.log(aw.dashboardText());

What it does

Heartbeats - Each agent calls aw.report(name, status) on a schedule. AgentWatch tracks health over time and marks agents as stale or offline based on configurable thresholds.

Cross-agent tracing - Actions are linked by trace ID and optional parent event ID. When agent-c fails because agent-b sent bad data that came from agent-a, the full chain is queryable.

Cascade detection - correlate(failureEventId) walks backward from any failure to the root cause, returning the full chain with timing and output at each step.

Alert de-duplication - The same alert type from the same agent within a time window collapses into one entry with an incrementing count. Severity auto-escalates: info (1x) -> warning (3x) -> critical (10x).

Forensic replay - replay(traceId) returns all cascade chains within a trace. Useful for post-mortem analysis when a single trace touched multiple agents.

OpenTelemetry export - Export traces as OTEL spans (GenAI semantic conventions). Works with Jaeger, Grafana, or any OTEL-compatible backend. Requires optional peer deps.


CLI

bash
npx @nicofains1/agentwatch demo                   # run the demonpx @nicofains1/agentwatch dashboard              # fleet health overviewnpx @nicofains1/agentwatch cascade <event-id>     # trace cascade from a failurenpx @nicofains1/agentwatch failures [agent]       # list recent failuresnpx @nicofains1/agentwatch alerts [agent]         # list active alertsnpx @nicofains1/agentwatch replay <trace-id>      # replay all cascades in a tracenpx @nicofains1/agentwatch mcp                    # start MCP server (stdio)

Set AGENTWATCH_DB to point to your database file. Default: agentwatch.db in the current directory.


MCP server

AgentWatch runs as an MCP server. Add it to your Claude Code or Cursor config:

Claude Code (~/.claude/claude_desktop_config.json or .claude/settings.json):

json
{  "mcpServers": {    "agentwatch": {      "command": "npx",      "args": ["@nicofains1/agentwatch", "mcp"],      "env": {        "AGENTWATCH_DB": "/absolute/path/to/agentwatch.db"      }    }  }}

Cursor (.cursor/mcp.json):

json
{  "mcpServers": {    "agentwatch": {      "command": "npx",      "args": ["@nicofains1/agentwatch", "mcp"],      "env": {        "AGENTWATCH_DB": "/absolute/path/to/agentwatch.db"      }    }  }}

This exposes 13 tools: agentwatch_dashboard, agentwatch_report_heartbeat, agentwatch_trace, agentwatch_cascade, agentwatch_replay, agentwatch_get_alerts, agentwatch_get_failures, agentwatch_get_trace, agentwatch_fleet_health, agentwatch_create_trace_id, agentwatch_alert, agentwatch_resolve_alert, agentwatch_dashboard_text.


API reference

Constructor

typescript
const aw = new AgentWatch({  db_path: 'agentwatch.db',        // SQLite file path  alert_window_minutes: 30,         // de-dup window for alerts  heartbeat_stale_minutes: 30,      // when to mark agents as offline});

Heartbeats

typescript
aw.report(agent, status, context?)     // status: 'healthy' | 'degraded' | 'error' | 'offline'aw.getLatestHeartbeat(agent)           // -> Heartbeat | undefinedaw.getFleetHealth()                    // -> AgentHealth[]

Tracing

typescript
aw.createTraceId()                                // -> string (UUID)aw.trace(traceId, agent, action, input, output, {  parentEventId?: number,  status?: 'ok' | 'error',                        // default: 'ok'  durationMs?: number,})                                                // -> TraceEventaw.getTraceEvents(traceId)                        // -> TraceEvent[]aw.getRecentFailures(agent?, limit?)              // -> TraceEvent[]

Cascade detection

typescript
aw.correlate(failureEventId)    // -> CascadeChain | nullaw.replay(traceId)              // -> CascadeChain[]

Alerts

typescript
aw.alert(agent, alertType, message)aw.resolveAlert(alertId)aw.activeAlerts(agent?)         // -> Alert[]

Dashboard

typescript
aw.dashboard()      // -> DashboardOutput (structured)aw.dashboardText()  // -> string (formatted for terminal)

OpenTelemetry export

Requires optional peer deps @opentelemetry/api and @opentelemetry/sdk-trace-base.

typescript
await aw.exportTraceToOtel(traceId, { serviceName: 'my-agents' });await aw.exportRecentToOtel(1); // last 1 hour

Storage

SQLite via better-sqlite3. The database file is created automatically on first use. WAL mode is on for concurrent reads.

Tables: heartbeats, trace_events, alerts.


License

MIT

来源:README.md,提交 d063d0d

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.3.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分