Turn context pressure into an explicit mode and budget.
A free zero-dependency set of pure functions that combines weighted signals into a 0–1 pressure score, maps it to three modes, and tracks token estimates, spend, remaining budget, and overage.
How it works
The exact pipeline, end to end.
How it actually works
Exactly what it does — and when.
The host feeds several pressure signals into the pure function and receives compressed mode plus should-compact. It uses that result as one decision input, records its own token estimate, and performs the actual compaction outside the library.
This vs the alternative
Why it's clearly worth it.
The shift it creates
- Context pressure is noticed after failure
- Compaction triggers are implicit
- Token estimates have no remaining-budget interface
- Combine several pressure signals into one inspectable score
- Trigger full, compressed, or emergency behavior at configured thresholds
- Track estimated token spend against a budget
Use it to…
Real ways people put CONTEXT-BUDGET — Pressure Meter + Token Budget to work.
Choose a context mode
Feed the current weighted signals into the pressure score and inspect the configured mode.
Trigger compaction
Use should-compact as one input to your host's context-management decision.
Track a token estimate
Record estimated spend and remaining budget around a bounded task.
What's inside
Who it's for
Long-running agent developers
need an explicit compaction signal
Prompt-budget maintainers
need spend and remaining values in code
Local library users
want pure functions with no disk or network access
Questions, answered
Ready to put CONTEXT-BUDGET — Pressure Meter + Token Budget to work?
Free download · no account needed · yours forever