AgentCost – local CLI,attributes token cost in Claude Code/Cursor/Codex sessions

Kashifdevfe12 pts0 comments

agentcost-cli · PyPI

Skip to main content<br>Switch to mobile version

Warning

You are using an unsupported browser, upgrade to a newer version.

Warning

Some features may not work without JavaScript. Please try enabling it if you encounter problems.

Search PyPI

Search

agentcost-cli 0.1.0

pip install agentcost-cli==0.1.0

Copy PIP instructions

Latest release

Released:<br>Jul 24, 2026

Local CLI that profiles token spend for AI coding agent sessions (Claude, Cursor, Codex, Ollama).

Navigation

Verified details

These details have been verified by PyPI<br>Maintainers

kashifdevfe

Unverified details

These details have not been verified by PyPI<br>Project links

Changelog

Homepage

Issues

Repository

Meta

License: MIT License (MIT)

Author: kashifdevfe

Tags

ai

agents

claude-code

cursor

codex

ollama

tokens

cost

cli

Requires: Python >=3.10

Provides-Extra:<br>dev

Classifiers

Development Status

3 - Alpha

Environment

Console

Intended Audience

Developers

License

OSI Approved :: MIT License

Operating System

OS Independent

Programming Language

Python :: 3

Python :: 3.10

Python :: 3.11

Python :: 3.12

Python :: 3.13

Topic

Software Development :: Quality Assurance

Typing

Typed

Report project as malware

Project description

AgentCost

Local open-source CLI that profiles what drives token spend in AI coding agent<br>sessions — not just totals. Real logs from your machine. No cloud, no auth, no dashboard.

pip install agentcost-cli<br>agentcost doctor<br>agentcost smoke -v

Which AI tools can you connect?

AI tool<br>Provider ID<br>How AgentCost connects<br>Status

Claude Code<br>claude<br>Reads local transcripts in ~/.claude/projects/**/*.jsonl<br>Supported

Cursor Agent<br>cursor<br>Reads ~/.cursor/projects/**/agent-transcripts/**/*.jsonl<br>Supported

OpenAI Codex CLI<br>codex<br>Reads ~/.codex/sessions/**/rollout-*.jsonl<br>Supported

Ollama (local)<br>ollama<br>Records via agentcost smoke or ollama-proxy into ~/.agentcost/ollama/<br>Supported

List adapters anytime:

agentcost providers<br>agentcost list --provider claude<br>agentcost list --provider cursor<br>agentcost list --provider codex<br>agentcost report --provider ollama -v

Not connected yet (good first issues)

ChatGPT web/app, Gemini CLI, GitHub Copilot Chat, Aider, Continue, Windsurf, Cline, OpenCode, etc.<br>These can be added as new provider adapters — see CONTRIBUTING.md.

Install

Requires Python 3.10+.

pip install agentcost-cli

The console command is still agentcost (PyPI name is agentcost-cli because agentcost is already taken by another project).

Or with pipx (isolated CLI install):

pipx install agentcost-cli

For contributors (editable install)

git clone https://github.com/kashifdevfe/AgentCost.git<br>cd AgentCost<br>pip install -e ".[dev]"

Community quick start (real local data)

agentcost doctor<br>ollama pull llama3.2:1b # if needed<br>agentcost smoke -v # real multi-turn local run + report<br>agentcost report --provider ollama -v

Default fallback model: llama3.2:1b (override with --model or AGENTCOST_OLLAMA_MODEL).

Example: what a good report looks like

FOUNDER SNAPSHOT (plain English)<br>This was a LOCAL session (llama3.2:1b). API dollar cost is $0 ...<br>Main driver: 84% of token volume came from `user_turn` ...<br>No major waste flags - session looks relatively healthy.

TOTALS<br>tokens in=188 out=34 ...<br>avg/turn in~62 out~11<br>time 2.8 s wall generation

BY CALL TYPE (share by tokens)<br>#############--- 84.2% user_turn -> Later user messages<br>###------------- 15.8% initial_prompt -> First user message

ANOMALIES / INSIGHTS<br>INFO [local_ollama] Ollama is local - API $ is $0 ...

WHAT TO DO NEXT<br>- Local run: optimize for latency/tokens, not dollars.

Cloud agents (Claude / Codex) show estimated $ instead of $0.

What founders should look for

Signal<br>Why it matters

Estimated $ (cloud)<br>Rough session bill before finance sees the invoice

Main driver %<br>Is spend from one prompt, or endless agent loops?

HIGH / WARN anomalies<br>Waste patterns: tool loops, context re-sends

Hottest tool<br>One tool (e.g. Read on the same file) eating the budget

Local $0 + time<br>For Ollama: money isn't the metric — tokens/latency are

Healthy: initial prompt owns a fair share; tool loops are short.

Unhealthy: tool_followup or one hot file is 60%+ of the session.

What developers should look for

Field<br>Meaning

in / out<br>Input vs output tokens per session or turn

cache_read / cache_write<br>Prompt-cache reuse (Claude etc.)

call type<br>initial_prompt, user_turn, tool_followup, text_response

quality=estimated/placeholder<br>Numbers may be incomplete — treat $ as directional

TOP CALLS (-v)<br>Heaviest turns + tool targets

Log summary lines<br>Grep-friendly one-liners in ~/.agentcost/ollama/*.jsonl

Ollama JSONL includes human fields, e.g.:

"summary": "turn=2 model=llama3.2:1b in=58 out=17 ms=900.1",<br>"request_preview": {"prompt": "...", "messages": 3},<br>"response_preview": "A token represents..."

Live chat example (Ollama proxy)

# terminal A<br>agentcost ollama-proxy

# terminal B<br>set OLLAMA_HOST=127.0.0.1:11435<br>ollama run llama3.2:1b

#...

agentcost ollama local claude codex install

Related Articles