Agent Observability

io.github.KryptosAI由 GitHub 帳號 KryptosAI 發布v1.0.7更新於 Oct 24, 2026

Trace AI agent execution: every tool call, every error, every dollar. Open source, local-first.

概覽

AI 產生的概覽

一個本地優先的 MCP 伺服器,把 AI 代理工作階段的工具呼叫、token 用量、決策與評級記錄到本機 SQLite 資料庫,並提供儀表板。

可以做什麼
記錄工具呼叫,包含名稱、所屬伺服器、耗時、狀態、輸入與輸出,並記錄每個工作階段的 token 用量與估算費用,記錄決策點(情境、選項、所選方案與理由),給出 A–F 工作階段評級及理由,再讀取完整工作階段報告或列出歷史工作階段及其評級、token 總量與費用。搭配的本機儀表板與 REST 介面提供工作階段、工具呼叫、token、決策、搜尋、統計與 JSON 匯出。
適用情境
當你想為 Claude Code、Cursor 或 opencode 的工作階段留下「飛行記錄器」時使用:查看執行了哪些工具、失敗原因、花費多少,並保留讀取或修改檔案的稽核軌跡。適合調校提示詞與估算開銷。
執行需求
透過 npx(套件名稱 agent-obs)以本機 Node.js 程序執行;未宣告驗證、環境變數或標頭。安裝會為偵測到的代理寫入 MCP 設定,資料保存在使用者家目錄下的本機 SQLite 資料庫。儀表板監聽本機埠 9400。
安裝前請注意
伺服器會記錄完整的工具輸入與輸出(輸出截斷至 64KB),其中可能包含代理接觸過的檔案內容、密鑰或 API 金鑰;README 稱資料留在本機,但稽核軌跡本身敏感。安裝會修改代理的 MCP 設定,並向代理規則檔加入自回報指令。費用數字為依公開定價的估算。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Agent Observability,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

agent-observability

[CI] [npm] [license]

Open source agent observability — see what your agents did, why they failed, and what it cost. Runs locally. No cloud required.

Quick Start

One command. No manual config. No copy-paste.

bash
npx agent-obs@latest setup

This auto-detects your AI agent (opencode, Claude Code, Cursor) and configures everything:

  • Adds agent-obs to your MCP config
  • Adds the self-reporting instruction
  • Tells you what to do next

Then restart your agent. Every action will now self-report.

bash
agent-obs dashboard    # http://localhost:9400 — see your sessions appear

What you'll see

After running a task in your agent, the dashboard shows:

  • Every tool call with duration and status
  • A-F session grade (how efficient was your agent?)
  • Cost per session in tokens and dollars
  • Full audit trail of what was read, edited, and executed

Manual setup (if setup can't detect your agent)

opencode: Add to opencode.json:

json
{  "mcp": {    "agent-obs": {      "command": "npx",      "args": ["-y", "agent-obs@latest", "server"],      "enabled": true    }  }}

Claude Code: Create .mcp.json:

json
{  "mcpServers": {    "agent-obs": {      "command": "npx",      "args": ["-y", "agent-obs@latest", "server"]    }  }}

Cursor: Add to Cursor Settings > MCP:

json
{  "mcpServers": {    "agent-obs": {      "command": "npx",      "args": ["-y", "agent-obs@latest", "server"]    }  }}

See Agent-Specific Setup below for detailed per-platform instructions including self-reporting directives.

Note: All data is written to a local SQLite database in ~/.agent-observability/. No data leaves your machine.

Proxy mode (fallback)

For agents that can't self-report, wrap any MCP server and every tool invocation gets traced automatically:

bash
agent-obs proxy --desc "fix login bug" -- npx @modelcontextprotocol/server-filesystem /tmp

Proxy mode captures only MCP tool calls (~30% of typical agent actions). Prefer the setup / MCP server approach above.

Agent-Specific Setup

Claude Code

  1. MCP Config — Create .mcp.json in your project root:
json
{  "mcpServers": {    "agent-obs": {      "command": "npx",      "args": ["-y", "agent-obs@latest", "server"]    }  }}
  1. Self-reporting instruction — Create .claude/instructions.md (or reference the existing SKILL.md under .claude/skills/agent-obs/SKILL.md):
markdown
After every tool call, report to agent-obs's log_tool_call.Start each task with start_session. End with end_session.
  1. Verify — Run agent-obs dashboard, open http://localhost:9400, and look for your session after the agent completes a task.

Cursor

  1. MCP Config — Add to Cursor's MCP settings (~/.cursor/mcp.json, or Settings → MCP → Add new global MCP server):
json
{  "mcpServers": {    "agent-obs": {      "command": "npx",      "args": ["-y", "agent-obs@latest", "server"]    }  }}
  1. Self-reporting instruction — Create .cursorrules (or .cursor/rules/agent-obs.md):
After every tool call, you MUST call the agent-obs MCP server's log_tool_call tool.Include toolName, status (success/error), outputSummary, and durationMs.Start each session with start_session and end with end_session.
  1. Verify — Run agent-obs dashboard, open http://localhost:9400, and look for your session after the agent completes a task.

Architecture

                   ┌──────────────────────────┐                   │   agent-obs server       │                   │    (self-reporting)      │                   │                          │                   │ Agent calls obs_record_* │                   │ tools directly via MCP   │                   │ • tool calls             │                   │ • token usage            │                   │ • decisions              │                   │ • grades                 │                   └──────────┬───────────────┘                              │                              ▼                   ┌──────────────────────────┐                   │     agent-obs proxy      │                   │ (fallback — MCP-only)    │                   │                          │MCP Client ───────▶│ intercepts tool calls ──▶│ MCP Server  (Claude/Cursor)   │ logs to SQLite           │  (filesystem,                   └──────────┬───────────────┘   github, etc.)                              │                              ▼                   ┌──────────────────────────┐                   │   ~/.agent-observability │                   │       SQLite DB          │                   │                          │                   │  • sessions              │                   │  • tool_calls            │                   │  • token_usage           │                   │  • decisions             │                   │  • grades                │                   └──────────┬───────────────┘                              │                              ▼                   ┌──────────────────────────┐                   │   agent-obs dashboard    │                   │     (port 9400)          │                   │                          │                   │  GET  /api/sessions      │                   │  GET  /api/sessions/:id  │                   │  GET  /api/search?q=     │                   │  GET  /api/stats         │                   │  POST /api/export        │                   └──────────────────────────┘

API Reference

REST Endpoints (Dashboard)

MethodPathDescription
GET/api/sessionsList all sessions. Query params: ?limit=20&offset=0&grade=B
GET/api/sessions/:idGet full session detail with all tool calls, tokens, decisions, and grades
GET/api/sessions/:id/tool-callsList tool calls for a session. Query params: ?status=error&server=filesystem
GET/api/sessions/:id/tokensGet token usage history for a session
GET/api/sessions/:id/decisionsGet decision points for a session
GET/api/searchFull-text search across tool call inputs/outputs. Query param: ?q=read_file
GET/api/statsAggregate statistics: total sessions, avg grade, total tokens, total cost
POST/api/exportExport session data as JSON. Body: { "sessionIds": ["abc123"], "format": "json" }
GET/api/healthHealth check. Returns { "status": "ok", "dbSize": "2.4MB", "sessionCount": 47 }

MCP Tools (Server Mode)

ToolParametersReturns
obs_record_tool_callsessionId, toolName, serverName, duration (ms), status (success/error), input, output{ "id": "call-uuid", "recorded": true }
obs_record_token_usagesessionId, inputTokens, outputTokens, model{ "totalTokens": 1850, "estimatedCost": "$0.023" }
obs_record_decisionsessionId, context, options, chosen, reasoning{ "id": "decision-uuid", "recorded": true }
obs_record_gradesessionId, grade (A/B/C/D/F), reasoning{ "grade": "B", "recorded": true }
obs_get_session_reportsessionIdFull session JSON with all calls, tokens, decisions, grade
obs_list_sessionslimit, offsetArray of { id, description, grade, createdAt, tokenTotal, estimatedCost }

What Gets Tracked

Every tool call

  • Tool name — e.g. read_file, execute_command, search_code
  • Server — which MCP server handled it
  • Duration — wall-clock milliseconds
  • Status — success or error
  • Input — full arguments passed to the tool
  • Output — full result returned (truncated at 64KB for storage)

Token consumption

  • Input tokens — prompt and context
  • Output tokens — generated response
  • Total tokens — sum per session
  • Per-call breakdown — token delta for each LLM round-trip

Cost estimation

Costs are estimated based on published API pricing:

ModelInput (per 1M tokens)Output (per 1M tokens)
Claude 3.5 Sonnet$3.00$15.00
Claude 3 Opus$15.00$75.00
GPT-4o$2.50$10.00
GPT-4 Turbo$10.00$30.00

Costs are tracked per session and displayed in the dashboard. You can add custom model pricing via ~/.agent-observability/models.json.

Session grades

Every session receives a letter grade based on efficiency and correctness:

GradeLabelCriteria
ACleanZero errors, minimal token waste, no unnecessary tool calls
BMinor issuesSome inefficiencies, but no failures
CInefficientExcessive token usage, redundant tool calls, recoverable errors
DRiskySignificant problems — failed tool calls, high cost, wrong tools chosen
FFailedErrors prevented task completion, or agent abandoned the session

Decision points

When the agent has multiple possible actions, it can record why it chose one over another. Example:

json
{  "context": "need to read a file — it could be at src/config.ts or lib/config.ts",  "options": ["read_file src/config.ts", "glob **/config.ts", "grep 'CONFIG' *.ts"],  "chosen": "glob **/config.ts",  "reasoning": "File might not exist at the expected path; glob guarantees finding it regardless of location"}

Decision points create an audit trail of agent reasoning, making it possible to understand not just what happened, but why.

Full audit trail

Every action is timestamped and linked to a session. The audit trail answers:

  • Who (which agent/user) accessed what data?
  • When did each tool call happen?
  • What data was read or modified?
  • Was the action authorized?

Grade System

Grades are assigned manually by the agent via obs_record_grade or automatically by the dashboard based on session statistics:

  • A = Clean — No issues detected. Every tool call succeeded, token usage was efficient relative to task complexity, and the session completed its stated goal.
  • B = Minor issues — Some inefficiencies (e.g., reading the same file twice, calling a tool that returned empty results and then trying it again). No failures.
  • C = Inefficient — Needs attention. Redundant tool calls, excessive token consumption, or recoverable errors that were eventually resolved.
  • D = Risky — Significant problems. Multiple failed tool calls, unusually high cost for the task, or the agent chose demonstrably wrong tools.
  • F = Failed — Errors occurred that prevented task completion, or the agent abandoned the session.

Grades accumulate over time. The /api/stats endpoint shows your average grade and grade distribution.

Why This Exists

AI agents are a black box. You tell Claude Code or Cursor to fix a bug, refactor a module, or add a feature — and minutes later you have a diff. But what actually happened in between? How many tool calls did it make? How many tokens did it burn? Which files did it read? Did it try three approaches before landing on one? You have no idea.

This isn't just academic curiosity. Without observability:

  • You can't estimate costs. A session that feels quick might have burned $5 in API calls. A session that felt slow might have cost $0.50. You're operating blind.
  • You can't debug failures. The agent produced broken code — was it because it read the wrong file? Used a deprecated API? Misunderstood the task? Without traces, you're guessing.
  • You can't improve your prompts. Is the agent reading too many files? Calling too many tools? Wasting tokens on irrelevant context? You need data to tune your system instructions.
  • You can't audit access. If an agent reads a file containing secrets or API keys, you should know about it. If it makes an unexpected network call, you need to see it.

Agent Observability gives you a flight recorder for every agent session. It answers: what happened, why it happened, and what it cost.

Provenance

This project combines ideas from three prior projects:

AgentShelf (Shopify AI readiness scanner)

AgentShelf scans a Shopify store's theme, apps, admin settings, and custom code to produce an AI readiness score. As it scans, it builds a full audit trail — every file read, every API call made, every finding logged with a timestamp and data source. Pattern adopted here: structured audit trail with per-action timestamps, data source attribution, and session-level summarization.

Veros (FHIR clinical ground truth)

Veros generates synthetic longitudinal patient records (FHIR R4) and uses them to validate clinical decision support agents. Its core principle: "no trace, no answer." Every snippet of clinical reasoning produced by an AI must be traceable back to the specific data element (lab result, medication, condition) that supports it. Pattern adopted here: decision point tracking — every agent choice must cite its basis, making reasoning auditable and contestable.

MCP Observatory

MCP Observatory secures MCP servers — testing them for vulnerabilities, schema drift, and attack surfaces before agents depend on them. It's used by 850+ developers weekly and powers CI pipelines for MCP server security. Use Observatory to secure your MCP servers. Use agent-obs to trace the agents that depend on them. Observatory validates; agent-obs observes.

Pattern adopted here: tool health scoring, session grading (A-F), and automatic degradation flags.

Open Source vs Cloud

This open source package (agent-observability on npm) is the core engine. It's MIT licensed and will always remain free and local-first:

  • CLI tools (proxy, server, dashboard)
  • Local SQLite storage
  • REST API
  • MCP server tools
  • Full audit trail, cost estimation, and session grading

A cloud version (app.agentobservability.dev) is in development with additional features:

  • Team dashboards with shared session history
  • Alerting (Slack/email when an agent's grade drops below C)
  • Historical analytics (cost trends, efficiency trends over months)
  • Role-based access control for audit trails
  • SOC 2 compliant infrastructure

The open source package will always be able to run independently. The cloud version is additive, not a replacement.

License

MIT

來源:README.md,提交 2658eef

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.0.7最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分