kayariyan28/ctxbudgeter — explained in plain English
Analysis updated 2026-05-18
Fit system instructions, documents, and tool results into a fixed token budget without random dropping.
Write tests that assert a context pack always includes required items and stays under a token limit.
Automatically mark cache-stable items for Anthropic, OpenAI, LangChain, or PydanticAI prompt caching.
| kayariyan28/ctxbudgeter | 0-bingwu-0/live-interpreter | 0xkaz/llm-governance-dashboard | |
|---|---|---|---|
| Stars | 2 | 2 | 2 |
| Language | Python | Python | Python |
| Setup difficulty | easy | moderate | hard |
| Complexity | 3/5 | 2/5 | 4/5 |
| Audience | developer | general | ops devops |
Figures from each repo's GitHub metadata at analysis time.
Runs entirely locally and makes no AI calls itself.
When you build AI agents, one of the hardest problems is managing what goes into each prompt. Language models have a limited context window, meaning you can only fit so many tokens (roughly, word pieces) in a single call. ctxbudgeter is a Python library that sits between your agent code and the AI model and decides, deterministically and with full audit trail, exactly which pieces of information to include, drop, compress, or mark for caching in each call. You give it a token budget and a collection of items: system instructions, documents, code files, memory notes, tool results, and the user's current request. Each item gets a priority and optional flags like required or cache-stable. When you compile the pack, the library selects what fits within the budget, explains why each item was included or excluded, and produces a context object ready to send to the model. Nothing is resolved at random, every run with the same inputs produces the same output, which makes it testable. The library includes a pytest-style assertion layer so you can write tests that check whether your context pack always includes certain required items, never includes sensitive data, stays under a token limit, and maintains a minimum quality score. It also provides cache-aware adapters that automatically set the right caching fields for Anthropic, OpenAI, LangChain, and PydanticAI. It works with LangGraph, CrewAI, PydanticAI, and your own agent loops. The core makes no AI calls itself, it runs locally and fast. The full README is longer than what was provided.
A Python library that deterministically decides which pieces of context fit into an AI agent's token budget, with a full audit trail.
Mainly Python. The stack also includes Python.
Setup difficulty is rated easy, with roughly 30min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.