Skip to main content

Real-time cost tracking for AI coding agents with budget limits, kill switch, and TUI dashboard.

Project description

agent-tally

PyPI version Python 3.9+ License: MIT GitHub stars

Real-time cost tracker for AI coding agents. Wrap any CLI agent, see a live cost ticker while it runs, and enforce budgets with an automatic kill switch.

Install

pip install agent-tally

Quick Start

# Track a Claude Code session
agent-tally run claude "refactor auth module"

# Set budgets
agent-tally budget set --daily 5.00 --session 1.00

# Watch costs live
agent-tally dashboard

Output while your agent runs:

$ agent-tally run claude "fix the login bug"
⠋ Running claude...  $0.42 │ 2.1k tokens │ 14s elapsed

Features

  • Live cost ticker — dollar amount updates in real-time as the agent runs, like a taxi meter
  • Budget enforcement — set daily and per-session limits; auto-kills the process at 100%, warns at 80% and 95%
  • Shell-level interception — wraps subprocess calls. No API hooks, no SDK changes, no config files
  • Cross-agent — works with Claude Code, Codex CLI, Gemini CLI, OpenClaw, Cursor, and any CLI tool
  • TUI dashboardagent-tally dashboard for a live overview of all tracked sessions
  • Webhook alerts — get Discord or Slack notifications when you hit budget thresholds
  • Export — dump cost history as JSON or CSV for your own analytics

CLI Reference

Command Description
agent-tally run <command> [args...] Wrap and track an agent
agent-tally budget set --daily 5.00 --session 1.00 Set budget limits
agent-tally budget show Show current budget and usage
agent-tally dashboard Live TUI cost dashboard
agent-tally summary [--by-agent|--by-model] [--since 7d] Usage summary
agent-tally export [--format json|csv] Export cost data
agent-tally agents List supported agents

How It Works

┌─────────────────────────────────────────────────────┐
│                   agent-tally                        │
│                                                      │
│  ┌──────────┐   ┌──────────────┐   ┌─────────────┐ │
│  │  CLI run  │──▶│   Wrapper    │──▶│  Subprocess  │ │
│  │  command  │   │  intercepts  │   │  (agent CLI) │ │
│  └──────────┘   │  stdout/err  │   └──────┬───────┘ │
│                  └──────┬───────┘          │         │
│                         │                  │         │
│                         ▼                  │         │
│                  ┌──────────────┐          │         │
│                  │ Token parser │◀─────────┘         │
│                  │ counts tokens│  (reads agent      │
│                  │ from output  │   output stream)   │
│                  └──────┬───────┘                    │
│                         │                            │
│              ┌──────────┴──────────┐                 │
│              ▼                     ▼                 │
│     ┌──────────────┐    ┌────────────────┐          │
│     │  Live ticker │    │ Budget checker │          │
│     │  $X.XX ████  │    │ warn @ 80/95%  │          │
│     └──────────────┘    │ kill @ 100%    │          │
│                         └───────┬────────┘          │
│                                 ▼                    │
│                    ┌────────────────────┐            │
│                    │  Webhook alerts    │            │
│                    │  Discord / Slack   │            │
│                    └────────────────────┘            │
└─────────────────────────────────────────────────────┘

agent-tally wraps your agent command as a subprocess. It parses the agent's output stream to count tokens in real-time, calculates cost using model-specific pricing, and displays a live ticker. If spending hits your budget limit, it kills the process automatically.

Supported Agents

Agent Status
Claude Code ✅ Supported
Codex CLI ✅ Supported
Gemini CLI ✅ Supported
OpenClaw ✅ Supported
Cursor ✅ Supported
Any CLI agent ✅ Generic support

Why agent-tally over tokscale?

agent-tally tokscale
Approach Active — wraps commands in real-time Passive — reads session logs after the fact
Live cost display ✅ Ticker updates as the agent runs ❌ Post-hoc only
Budget enforcement ✅ Kill switch at budget limit ❌ No enforcement
Kill switch ✅ Auto-terminates runaway agents ❌ Not possible (after the fact)
Setup Wrap your command, done Parse exported logs

tokscale is great for retroactive analysis. agent-tally is for when you want to control spend while it's happening.

Contributing

  1. Fork the repo
  2. Create a branch: git checkout -b feat/my-feature
  3. Make changes and add tests
  4. Run pytest
  5. Open a PR

Bug reports and feature requests welcome in Issues.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_tally-0.9.0.tar.gz (68.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_tally-0.9.0-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

Details for the file agent_tally-0.9.0.tar.gz.

File metadata

  • Download URL: agent_tally-0.9.0.tar.gz
  • Upload date:
  • Size: 68.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for agent_tally-0.9.0.tar.gz
Algorithm Hash digest
SHA256 85941f4ad419270cbc5ecf165ab329cf1dab9a540c7d64bda646ac00383159f2
MD5 c68884bd52492bed4aea8cc81043b793
BLAKE2b-256 d735166d8cc6632a57495615b8ab2494d789db713c712c750c5d0d2855d9ef52

See more details on using hashes here.

File details

Details for the file agent_tally-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: agent_tally-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 38.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for agent_tally-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44680153ec0f07c49949f2208624796085abf082cd4c2efae61297ec4d73dd4b
MD5 4aa53dad64325cb002bc5153cb13f138
BLAKE2b-256 cadf380738b07a498f70fab7499d56821b45e3923254c778a9b5fd3ee6fc16aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page