Add OpenClaw provider#103
Conversation
Tracks token usage and cost across OpenClaw satellite agents by reading JSONL session files from ~/.openclaw/agents/*/sessions/. Each satellite directory becomes a project. Local Ollama models (qwen family) are pinned to $0 regardless of LiteLLM matches. Paid models route through the existing LiteLLM pricing, with the session's embedded cost field as fallback for models not yet in the pricing catalog. Archived session files (.deleted.*, .reset.*) are skipped during discovery. Override base directory with OPENCLAW_AGENTS_DIR.
The .deleted.* and .reset.* suffixes are OpenClaw's session rotation scheme, not user deletion. The data in rotated files is intact and represents real usage that should be counted. Skipping them caused a ~6x undercount against a representative multi-agent setup. Safe to include all *.jsonl* files because the dedup key is sessionId+messageId (content-derived), so any accidental overlap between a live file and a rotated copy is handled by the existing seenKeys logic in the parser. Updated the corresponding test to assert inclusion rather than skip.
|
Post-review gut-check from one of my own users surfaced a bug I shipped in the first pass. OpenClaw archives session files by renaming them with a |
|
OpenClaw support has been merged in #175. Thanks for the contribution! Would you mind sharing a screenshot of your CodeBurn report? |
|
Hi, The OpenClaw parser deduplicates by Severity: action required | Category: correctness How to fix: Make dedup keys globally unique Agent prompt to fix - you can give this to your LLM of choice:
Spotted by Qodo code review - free for open-source projects. |
Summary
Adds a new
openclawprovider so codeburn can track usage across OpenClaw multi-agent orchestration sessions. OpenClaw writes JSONL session files per satellite agent in a format very similar to Claude Code's, but with a slightly differentusageschema (usage.input/usage.outputinstead ofinput_tokens/output_tokens).Each satellite directory under
~/.openclaw/agents/becomes a project in the dashboard:main,douyun, etc. — paid API agents (GPT-5.4, Kimi K2.5) priced via LiteLLMivy,lilith— local Ollama agents (Qwen family) pinned to $0How it works
discoverSessions()enumerates~/.openclaw/agents/*/sessions/*.jsonl(override viaOPENCLAW_AGENTS_DIR), skipping.deleted.*and.reset.*archives.ParsedProviderCallper assistant message withusage.exec→Bash,read→Read, etc.).ollamaor model name containsqwen) force $0, even if LiteLLM accidentally matches. Belt-and-suspenders.usage.cost.totalthat OpenClaw records itself. Same fallback pattern as the OpenCode provider.Test plan
npm run buildgreennpx vitest run— 19 files, 256 tests pass (18 new tests intests/providers/openclaw.test.tscovering discovery, parsing, pricing, display names)codeburn today --provider openclawshows per-satellite breakdowncodeburn today(unified) shows OpenClaw alongside Claude/Codexqwen3:32bmoonshotai/kimi-k2.5correctly priced via LiteLLMopenclaw:<sessionId>:<messageId>prevents re-counting across re-runsNotes
src/providers/openclaw.ts(226 lines)src/providers/index.tsalongside existing core providerstests/providers/openclaw.test.ts(new),tests/provider-registry.test.ts(1 line updated)Happy to iterate on naming, display strings, or the pricing fallback heuristic if you'd prefer a different approach.