agent-usage-tracker
Track AI agent token usage, model costs, and budget thresholds with a TypeScript and SQLite workflow. Use when the user wants to instrument agent runs, calculate token spend, enforce per-session or time-window budgets, or analyze usage by model, session, or time range.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/imgolye/agent-usage-trackerAgent Usage Tracker
Use this skill when you need local token accounting for AI agents.
What it provides
- Real-time token usage persistence in SQLite
- Cost calculation based on per-model pricing
- Budget thresholds with persisted warning and blocking states
- Usage statistics grouped by time window, session, or model
Files to use
src/UsageTracker.ts: ingestion, storage, and reportingsrc/CostCalculator.ts: pricing catalog and cost mathsrc/BudgetManager.ts: budget policy evaluationexamples/basic-usage.ts: end-to-end usage exampletests/: reference behavior for tracking, budgeting, and aggregation
Recommended workflow
- Instantiate
UsageTrackerwith a SQLite path or:memory:for tests. - Register model pricing with
CostCalculator. - Record each agent interaction with prompt tokens, completion tokens, session id, and timestamp.
- Save reusable budgets with
BudgetManager.setBudget, then callevaluateBudgetbefore or after new work to warn or stop when a limit is exceeded. - Use
UsageTracker.getUsageSummaryorgetTimeSeriesfor reporting.
Integration notes
- Store token counts at the moment the provider returns usage metadata.
- Keep model ids normalized. Pricing lookup is exact by model id.
- Use
metadatafor provider-specific fields such as request id or tool name. - For sliding-window budgets, query usage by
startTimeandendTimebefore dispatching new work.
Output expectations
This skill ships as a local Node.js package with tests and examples. Extend CostCalculator if your provider pricing changes.
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-imgolye-agent-usage-tracker": {
"enabled": true,
"auto_update": true
}
}
}Related Skills
xiaohongshu-viral-content
小红书爆款文案生成器。基于热门模板和数据驱动,生成高转化率的小红书内容。
daily-hot-push
每日推送中国热榜TOP10到飞书。从微博、知乎、百度、36氪筛选最重要的新闻,智能排除明星八卦和主观评论。
agent-task-queue
Build and operate a multi-agent task queue in OpenClaw with priority queues, delayed/dead-letter queues, scheduling, retry/timeout control, dependency management, parallel execution, and execution tracking using the bundled TypeScript runtime.
Doc Genius
Skill by imgolye
Crypto Scope
Skill by imgolye