MIT License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

深度技术分析:vivekchand/clawmetry

项目背景与痛点

vivekchand/clawmetry 项目提供了一种名为 “Clawmetry” 的工具,用于监控和治理多个 AI 代理运行时。在 AI 领域,开发者常常需要运行和监控多种 AI 代理,比如 Claude Code、Cursor、OpenAI Codex、GitHub Copilot 等。尽管每种代理都有其独特优势,但统一管理和监控这些代理的运行时信息(如实时 Token 成本、会话、工具调用等)却是一个相当大的挑战。此外,还要考虑不同代理之间的异步通信和数据流管理。Clawmetry 通过提供零配置的可观测性和治理功能,显著简化了这一任务,填补了现有工具的空白。

核心技术揭秘

Clawmetry 项目采用了模块化和面向服务的设计思路,其架构被拆分成多个服务层,协调以实现监控和治理功能。为方便理解,我们可以从整体流程入手,再逐步分解到具体实现。

首先,用户请求将被传递给 Clawonomy 服务,这里负责接入和解析不同类型的 AI 代理。随后,Clawmetry 服务对解析后的数据进行处理,并将处理后的信息推送至 Meteronator 服务,后者负责实时计算 Token 成本,并监测代理运行时的健康状况。

graph TD A[用户请求] --> B("Clawonomy 服务") B --> C("解析与接入代理") C --> D("Clawmetry 服务") D --> E("数据处理和聚合") E --> F("Meteronator 服务") F --> G[实时成本监控] F --> H[状态同步]

关键技术栈包括但不限于 Golang 和一些开源库。分布式服务架构使得 Clawmetry 能够高效管理不同种类的代理运行时数据。它不仅支持高效的分布式数据处理,还能确保数据流的稳定性与安全性。

功能亮点与差异

与其他同类工具相比,Clawmetry 的核心亮点在于其零配置的可观测性和治理功能。用户无需为每种代理配置复杂的监控参数,Clawmetry 能够自动对接和解析代理信息,提供统一的监控界面和实时数据分析。此外,其广泛兼容性使其成为管理多种 AI 代理的理想选择。

值得一提的是,Clawmetry 注重实时反馈和自动数据流处理,使得运维人员能够快速响应代理运行中的异常状况。实时监控功能能够帮助团队在发现异常时立即采取行动,避免潜在风险。

应用场景与落地建议

在生产环境中使用 Clawmetry 时,需要注意以下几点:

  1. 资源分配:在高并发场景下,确保网络带宽和服务器资源充足,以维持服务稳定性和响应速度。
  2. 监控配置:虽然零配置是其亮点,但仍需根据实际业务需求调整监控范围与频次,以确保监控数据的精准和高效。
  3. 多代理适配:务必测试并验证 Clawmetry 对多代理运行时的兼容情况,特别是一些定制化代理。

Clawmetry 适合以下场景:

  • 多代理管理:适用于管理多个不同类型的 AI 代理,如 Claude Code、GitHub Copilot 等。
  • 实时监控:需求实时监控 Token 成本和工具调用情况的场景。
  • 智能运维:系统的自动运维与异常检测需求较高的场景。

综合评价

优点

  1. 零配置的可观测性:用户无须繁琐配置即可获得全面监控支持。
  2. 广泛兼容性:能够管理多种类型的 AI 代理。
  3. 实时反馈:准确监控和提醒运行时异常。

缺点

  1. 资源消耗较高:高并发场景时,资源需求大。
  2. 高度依赖网络:网络不稳定时,可能导致服务中断。

总体来看,Clawmetry 在可观测性和治理方面表现卓越,特别适合 AI 代理的统一监控与运维。项目的设计和实现思路值得深入学习和借鉴。

简要分析

热度分
544
价值分
257
活跃状态
活跃

语言占比

Batchfile
CSS
Dockerfile
HTML
JavaScript
Makefile
NSIS
PowerShell
Python
Shell
TypeScript

Release

README

ClawMetry

PyPI version PyPI Downloads GitHub stars License: MIT OpenSSF Scorecard Security policy Egress: documented

An agent can make a hundred tool calls without making progress. ClawMetry reads the session files your coding agents already write, and puts the timeline, the tool calls and whatever token and cost data the runtime exposes into one view — so you can tell a long run that is working from one that is stuck.

Works with 32 AI agent runtimes — Claude Code, OpenAI Codex, Hermes, OpenClaw & 28 more. One dashboard for your whole agent fleet. (the full list, generated from the catalogue.)

🌐 Read this in: English · 简体中文 · 日本語 · 한국어 · Español · Português (BR) · Français · Deutsch · हिन्दी · العربية · Русский · more →

One command. Zero config. Auto-detects everything.

pip install clawmetry && clawmetry

Opens at http://localhost:8900. Zero config: it finds the agent runtimes you already have, reads them read-only, and changes nothing about how they run.

ClawMetry dashboard: every AI agent runtime on one machine with 24h and lifetime cost per agent

Before you install

What it does Reads the session files and logs your agents already write. No SDK, no code change, no instrumentation in your app.
What you see Session timeline, tool-by-tool replay, token and cost breakdown, and trajectory signals (looping, repeated failures) — per runtime.
What’s free pip install clawmetry reads OpenClaw, NVIDIA NemoClaw, Goose and Qwen Code with no account, no key and no network call. The other 28 — Claude Code, Codex, Cursor and the rest — are read by the closed-source clawmetry-pro companion, which arrives with the 7-day trial or a plan — see docs/ENTITLEMENTS.md for the exact split.
How to start pip install clawmetry && clawmetry, then open localhost:8900. No agents on this machine yet? clawmetry --sample opens on three labelled synthetic sessions.
What leaves your machine No session data, unless you run clawmetry connect. Two things do run by default, both opt-out and neither carrying session content: an anonymous install ping and a PyPI version check. Every destination is inventoried in docs/EGRESS.md, rebuilt from a wire capture rather than from reading comments.

Two limits worth knowing before you judge the output: runtimes expose very different data (some publish no cost at all — the matrix says which, per runtime), and observing an action is not the same as being able to block it (which controls are real, per runtime).

Works with 32 agent runtimes

Free in the open source app: 🦞 OpenClaw · 🟩 NVIDIA NemoClaw · 🪿 Goose · ◈ Qwen Code

On a paid plan: ◆ Claude Code · Cursor · 🐙 GitHub Copilot · ⬡ OpenAI Codex · ♊ Gemini CLI · 💗 Lovable · ⠕ Replit Agent · 🖇 Cline · 🙌 OpenHands · 🧑‍💼 OpenWorker · 🎭 Muse Code · 🏛️ OpenExecutive · opencode · Aider · 🔗 n8n · 🅳 Devin · 🪐 Antigravity · Grok Build · 🤖 Grok Bot · ⚡ Hermes · Pi · Deep Agents · 🌙 Kimi CLI · 🐋 DeepSeek Harness · 🦾 Exo · NanoClaw · PicoClaw · QM

Every runtime gets the same dashboard. Run several at once and the header switcher re-scopes every tab to one of them.

Built your own agent on an SDK instead? The interceptor tracks its LLM calls too. See docs/SDK_TRACKING.md.

Building with a humanoid robot? The free, open-source Asimov 1 connector imports Menlo SDK recordings and provides an optional observation collector and application tracing. This support is experimental. Physical hardware qualification is pending.

Jumper observation is also built into the same open-source package. Its application telemetry, task decisions and incidents appear in the shared Physical AI view. Mizu’s separate scene and skills demo imports this built-in adapter; it is not another observer plugin to install.

What you get

  • Sessions & transcripts: what each agent did, turn by turn, with replay
  • Cost & tokens: per runtime, model, session and day, with anomaly flags
  • Flow: live diagram of messages moving through channels, models and tools
  • Brain: the reasoning and tool-call event stream as it happens
  • Context blowout: window utilization sized per provider, compaction vs forced overflow, plus a per-runtime map of what we can’t see (how)
  • Memory & skills: the files and skills each runtime actually loaded
  • Health & logs: disk, memory, error rates, rate limits, live log stream
  • Alerts: budget caps, error spikes, agent-offline, routed to Slack, Discord, PagerDuty, Telegram, Email
  • Approvals: pause risky tool calls before they run and approve from your phone (how)

Context blowout, and what watching costs

Two questions worth answering before you trust any agent-comparison tool.

How does it handle context-window blowout across runtimes?

A utilization percentage is only as honest as what it divides by. ClawMetry sizes the window per provider from a table you can read and PR, covering Anthropic, OpenAI, Google, xAI, DeepSeek, Kimi, Qwen, Mistral, Llama and GLM. It does not measure all 32 runtimes with one vendor’s ruler. That matters: a 300K GPT-5 turn scored against Anthropic’s 200K reads “>100%, blown” when it is really at 75% of GPT-5’s 400K. The same ruler hides a genuinely overflowed 130K DeepSeek turn as a comfortable 65%.

Every window ships with its provenance: model_table, explicit_marker, observed_floor, or an honest default when we don’t know the model. A gauge built on a guess never renders with the same authority as one built on a lookup.

ClawMetry can only see compaction events on some runtimes. So GET /api/context-coverage reports, per runtime, whether a zero means “ran clean” or “we’re blind”. A 0 that actually means blind says so. Full detail

What does the instrumentation cost?

Path Added to your agent Default?
Session-file tailing (all 32 runtimes) 0. Separate process, no ClawMetry code in your agent on
HTTP interceptor (CLAWMETRY_INTERCEPT=1) +0.44 ms per LLM call, or 0.009% of a 5s call off
Pre-tool hook gate (warm cache) +44 ms per gated tool call, over a 36 ms interpreter floor off
Enforcement proxy +9.7 ms per LLM call off

Daemon host cost: 2,762 events/sec ingest, 710 bytes/event on disk (67.7 MB per 100k events), and ~12% of one core sustained on a busy install. That last number is over our own stated 5-10% budget, so it is published as a bug to chase rather than left off the page.

Measured on an Apple M2 Pro with benchmarks/overhead.py. The harness runs each condition in a separate process, alternates their order, and refuses to print a number when the rounds disagree on its sign. Run it on your own machine in a minute:

pip install clawmetry && python -m benchmarks.overhead

Every path is measured, including the hook gates and the enforcement proxy, and the harness runs on Linux, macOS and Windows in CI. Two results worth knowing: the proxy costs about seven times more on Windows than on Linux, and the daemon currently sustains about 12% of one core, over our own 5-10% budget. The raw JSON, the method, and what is still unmeasured are in docs/OVERHEAD.md.

Pricing

Plan What it covers Price
Free OpenClaw + NVIDIA NemoClaw + Goose + Qwen Code, full dashboard, local only $0
Starter Every other runtime above, fleet view, cloud sync $9 per node / month
Pro Starter + control and evaluation: approvals, tool-risk policies, evals, anomaly detection, cost optimizer, OTel export, tamper-evident audit log $19 per node / month

Annual plans, Enterprise and the current numbers live at clawmetry.com/pricing. Self-hosted license keys work without the cloud (clawmetry license). The exact free/paid split is in docs/ENTITLEMENTS.md.

Your data stays on your machine

ClawMetry reads local session files and logs. No session data leaves your box unless you run clawmetry connect — no prompts, replies, tool arguments, file contents or log lines. When you do connect, the snapshot is end-to-end encrypted with a key that never leaves your machine, and decrypted in your browser. If a node has no key, the upload is skipped rather than sent in the clear, and no server response can turn that off.

Two things do run by default before you connect, both opt-out and neither carrying session data: an anonymous install ping and a version check against PyPI. A default install also looks up your public IP once for a startup banner line. Every destination, what it carries and how to switch it off is listed in docs/EGRESS.md; self-hosted, repointed and air-gapped installs make no discretionary outbound calls at all.

The decryption happens in your browser, in code we serve you. That used to be a promise; it is now something you can check. Every line that touches your key lives in one readable file, clawmetry/static/js/cm-e2e.js, which ships inside the wheel and is served verbatim, pinned with a Subresource Integrity hash. To confirm the browser runs what we published:

curl -s https://app.clawmetry.com/static/js/cm-e2e.js -o served.js
pip download --no-deps clawmetry==$(clawmetry --version | tr -d 'a-z ') -d /tmp/cm
unzip -p /tmp/cm/clawmetry-*.whl clawmetry/static/js/cm-e2e.js > published.js
diff served.js published.js && echo identical

What that does not prove: we serve the page that loads the file, so we could serve a different page. Integrity hashes protect you from a compromised CDN, not from the vendor. What you gain is that any substitution has to be deliberate, visible in the page source, and different from an artifact on PyPI that anyone can fetch. Self-hosting or staying local-only removes the dependency entirely.

Install

pip install clawmetry     # then: clawmetry

Or the one-liner: curl -sSL https://raw.githubusercontent.com/vivekchand/clawmetry/main/install.sh | bash

Needs Python 3.8+ on macOS, Linux or Windows, and at least one agent runtime on the same machine. Docker instructions: docs/DOCKER.md.

Or let the agent set it up for you. The agent-kill-switch skill teaches Claude Code, Codex, Cursor, Gemini CLI, Copilot or OpenCode to install ClawMetry, report what the agents on the machine are doing and spending, stop one session on request, and hold risky tool calls for approval:

npx skills add vivekchand/clawmetry --skill agent-kill-switch

Docs

Runtime compatibility What each adapter reads, and how to add a runtime
Context blowout Per-provider windows, compaction vs overflow, per-runtime coverage
Overhead What instrumentation costs, measured, with the harness to reproduce it
Entitlements Free vs paid, tier matrix, license CLI
Approvals & policies Pre-execution gating, risk scoring, phone approvals
OpenTelemetry Export traces anywhere, ingest OTLP from anything
Bring your own agent AWS AgentCore, Pydantic AI, LangChain end to end, with runnable examples
SDK tracking Cost attribution for agents you built yourself
Chat channels The chat adapters shown in Flow
NemoClaw / OpenShell Sandboxed NVIDIA NemoClaw setups
Docker Image, compose, volume mounts
Architecture · Development How it works inside; running from source
Telemetry The anonymous install and desktop-open pings, and how to turn them off

Screenshots

Every number below is from one real machine, read-only, with nothing seeded.

It tells you when something is wrong, not just what happened. Two anomaly banners at the top: spend running 7x the daily average, and a 4.2x cost spike. Below them, 324 of 667 recent sessions carrying a waste signal, itemised by cause.

Overview: spending anomaly and cost spike banners over live agent work

It shows you where the money went, in every window. $252.47 today, $513.15 this week, $1,312.92 this month, each with the tokens behind it and how much of it your subscription already covers. Below that, about $1,128/mo itemised as recoverable and $17,256/mo already saved by cache reuse.

Cost: today, this week and this month, with an efficiency grade and itemised savings ideas

It draws how a message becomes an answer. The live flow diagram: you, the channel it arrived on, the gateway, the model answering right now, and every tool it reached for. Nodes light up as work moves through them.

Flow: live diagram from you through the gateway to the model and its tools

Every agent on the machine, in one table. What it runs, what it costs in the last 24 hours and over its lifetime, when it was last seen, who owns it, and whether a subscription is covering the bill. 14 agents here, 3 sessions working, 13 quiet.

Agents: every runtime on the machine with cost, owner, last seen and current work

It shows where a turn’s time and money went, tool by tool. One turn of a real session: 11 tools in 11.2 minutes for $1.16. Every Bash call and model call gets its own bar on the timeline, so the command that ran for 4.1 minutes and the one that ran for 226ms are told apart at a glance.

Sessions: one agent turn on a timeline, every tool call with its own duration and the turn's cost

It grades the work, not just the spend. An A this week: 54 tasks came back clean, 2 rough ones cost $48.57, and the runs with too little activity to judge are left out of the grade instead of being counted as wins. Each rough run links to its trace.

Quality: this week's report card with the rough runs and what they cost

It shows why the context window keeps filling up. 715K of a 1M-token window on the latest turn, an 83.3% peak, 4 compactions that all fired proactively rather than on an overflow, and the utilisation of every turn behind it.

Context usage: window utilisation per turn, compaction events and tokens reclaimed

Detection runs without you configuring anything. The built-in detectors are on from install: agent went quiet, telemetry feed stopped, cost spike, token burst, errors climbing, error spike, budget threshold, threat signature matched, security tool finding, security posture changed. Your own rules are optional on top.

Alerts: built-in detectors plus optional custom rules

Holding a risky call is opt-in, and ships off. Recursive deletes, force pushes, sudo, secrets, package installs and outbound calls each get a rule you can turn on. Until you do, ClawMetry watches and changes nothing. Once one is on, matching calls wait here (or on your phone) for an approve or a deny.

Approvals: protection rules for risky tool calls, all off until you enable them

More, per runtime: docs/RUNTIME_SCREENSHOTS.md.

Recognition

ClawMetry - #5 Product of the Day on Product Hunt

Star History

Star History Chart

License

MIT · Built by @vivekchand · clawmetry.com

评论

暂无评论