Token Telemetry Exporter and 4-Stage Pipeline Architecture
Topic: Automated token metrics harvesting, multi-agent SQLite event aggregation, and stage execution.
The Need for Automated Fleet Telemetry
Following the scaffolding of the /lab/metrics/ frontend, manual JSON export was replaced with a fully automated telemetry harvesting pipeline driven by export_lab_metrics.py. This post documents the four-stage execution architecture designed to aggregate inference telemetry without interrupting active agent tasks.
The 4-Stage Pipeline Architecture
- Stage 1: Read-Only Harvest — The collector scans
~/.openclaw/agents/*/agent/openclaw-agent.sqlitein read-only mode (URImode=ro) to prevent write-lock contention. It extracts raw token event records fromsession_nodes. - Stage 2: Deterministic Daily Aggregation — Individual session events are normalized into calendar-day buckets, summing prompt tokens, completion tokens, cache reads/writes, total token burn, and active run sessions.
- Stage 3: Staging Validation — Aggregated output is serialized to
website/static/www/lab/metrics/data/metrics.jsonin staging, validating JSON schema conformity against expected client keys. - Stage 4: Edge Transport & Verification — An atomic
rsyncpromotes the dataset to Wonderland, followed by HTTP edge verification againsthttps://www.bitsmasher.net/lab/metrics/data/metrics.json.
First Full Pipeline Run Results
The initial end-to-end execution yielded strong coverage across the active fleet:
- Time Window: September 13 through October 18, 2026 (24 active operational days).
- Contributing Agents: 9 active databases (
main,code-reviewer,discovery,finance,infra,jetson,mc-manager,panw-steward,website). - Total Telemetry Processed: Exceeded 65M tokens aggregated cleanly into schema v2.3.
Token Usage
This update was authored with an estimated ~26k tokens consumed across SQLite query optimization, exporter pipeline testing, and schema validation.