Show HN: Tokencap – Token budget enforcement across your AI agents

Show HN (score: 5)
Found: April 04, 2026
ID: 4023

Description

Other
Show HN: Tokencap – Token budget enforcement across your AI agents I built this after hitting the same wall repeatedly — no good way to enforce token budgets in application code. Provider caps are account-level and tell you what happened, not what is happening.

Two ways to add it:

  # Direct client wrapper
  client = tokencap.wrap(anthropic.Anthropic(), limit=50_000)

  # LangChain, CrewAI, AutoGen, etc.
  tokencap.patch(limit=50_000)  
Four actions at configurable thresholds: WARN, DEGRADE (transparent model swap), BLOCK, and WEBHOOK. SQLite out of the box, Redis for multi-agent setups.

One design decision worth mentioning: tokencap tracks tokens, not dollars. Token counts come directly from the provider response and never drift with pricing changes.

Happy to answer any questions.

More from Show

Show HN: Ccgs – Collaborative Claude Code sessions, stored in Git branches

Show HN: Ccgs – Collaborative Claude Code sessions, stored in Git branches My team uses Claude Code daily, and the sessions have become some of the most useful artifacts we produce. But they&#x27;re trapped in ~&#x2F;.claude&#x2F;projects&#x2F; on whichever laptop they happened on. There&#x27;s no good way to hand a colleague &quot;the session where I untangled the migration&quot; so they can claude --resume it and keep going from where I left off. Enter ccgs: Share Claude Code sessions through an orphan branch (@ccgs&#x2F;&lt;name&gt;) in your existing repo&#x27;s remote<p>- Session files carry the author&#x27;s absolute paths. On pull, ccgs rewrites the working dir back to your path so resume actually works — surgically editing only the structural cwd field, not a blind find-and-replace that would happily corrupt the transcript.<p>- Everything goes through git plumbing (hash-object&#x2F;commit-tree&#x2F;update-ref) against a throwaway index. It never touches your working tree, index, or current branch, and it&#x27;s fine with a dirty tree. It will not git checkout something behind your back.<p>To try it without installing: `npx claude-git-sessions`. This also incidentally allows you to move a directory and carry the claude code transcripts with it (just push first, then move the directory, then pull)<p>IMPORTANT CAVEAT: Unless you have a very good security hygiene, your Claude Code sessions are likely full of sensitive information such as environment secrets. Use with caution and avoid using on public repositories. Branches used by ccgs are prefixed by `@ccgs&#x2F;` so you can easily filter them out.<p><i>This project was written by and with Claude Code. This Show HN was not.</i><p>(Reposted with URL fixed)

No other tools from this source yet.