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 分