Cut Your LLM Token Costs for Free with ContextPress ContextPress, a Python library that compresses LLM context through rule-based logic rather than model calls, added five new compression stages since its initial release, according to a follow-up post by its developer. Benchmarks on 222 real conversation items across low, medium, and high presets — 666 runs total — showed the low preset cutting 6% of tokens while retaining 98.4% of hard facts, with the high preset delivering roughly eight times the savings at a real cost to retained facts. The library installs via pip and exposes a ContextManager class whose compress method takes a token_budget parameter, with three further stages — contractions, wordy-phrase compression, and number normalization — built but not yet enabled in any preset. Your API bill grows every time your context gets longer. Input token cost is not usually the biggest number on your bill, but it is the most important part you can actually control. Noise, repeated instructions, and unnecessary detail in your context also push the model toward longer, more expensive answers, so the cost adds up on both ends. Another gain here is optimizing the opportunity cost. As a developer, I work with a limited budget for coding agents. The more efficient I am with that budget, the harder I can push those agents, and the more I get done with them. Using ContextPress, I got more out of my coding agents on the same monthly budget, and it did not cost me anything extra to do it. A few things ContextPress does not need: ContextPress cuts tokens by summarizing context, removing noise, and shortening long words and phrases, all through plain rule-based logic, not a model call. There are more advanced tools inside the package too, for when you need them. As a quick taste: utilization becomes usage, and application programming interface becomes API. Just do this: pip install contextpress python from contextpress import ContextManagercm = ContextManager type="chat" compressed = cm.compress messages, token budget=2000 That is the whole integration. Every token ContextPress removes is a token you stop paying for. I first wrote about ContextPress here: Introducing ContextPress https://pub.towardsai.net/introducing-contextpress-the-python-library-that-refactors-your-llm-context-c57965617edb . This is the follow-up: what got added since, and the numbers behind it. Since that first piece, ContextPress picked up five new stages. Lexical swaps expensive words for cheap synonyms, utilisation/utilization becomes use. Abbrev shortens roughly 300 common long forms, application programming interface becomes API. Alias catches a phrase repeated three or more times, spells it out once, then shortens every mention after. Structure minifies embedded JSON in tool payloads and RAG chunks. Trim, only on the high preset, drops the middle of a long thread and keeps the opening, the recent turns, and any tool call pairs intact. Three more stages, contractions, wordy-phrase compression, and number normalization, are built and ready, just not switched on in any preset yet. One sentence shows most of it at once. Sample Before: In order to utilize the API effectively, due to the fact that rate limits apply, we should implement caching for the application programming interface calls we make on a daily basis. Sample After, low preset : To use the API effectively, because rate limits apply, we should implement caching for the API calls we make daily. Practicically the same input, but with fewer tokens, you save money. For the benchmarking, I used tokens saved and critical information loss as the main KPIs, both measured deterministically. LLM as a judge does not work well in this particular case, because whether a URL, a date, or an ID survived compression is a yes or no fact, not a judgment call. Asking a model to grade that just adds noise and cost, and cost is the one thing this whole library is trying to remove. So the benchmark runs on 222 real conversation items, chats, agent tool threads, and RAG file contexts, across all three presets: low, medium, and high. That comes out to 666 runs total, a coincidence, not a reference to the number of the beast, and the whole thing finishes in about four minutes. The check works like this: pull every hard fact out of the raw text first, URLs, versions, dates, IDs, then confirm each one survives compression at a token boundary. A stray “10” hiding inside “2010” does not count as a survivor. Results: low stays near-zero-risk: 6% improvements to the budget while 98.4% of every fact still there. high is the deep cut for a hard budget: about eight times the savings, at a real cost to retained facts. medium, roughly half of high's token savings for about the half its critical loss. choose based on your intent. For a typical chat, median critical loss is 0% on both low and medium. The only preset where the median conversation loses anything is high, and that is trim doing exactly what it is supposed to do, dropping the middle of a long thread on purpose. Presets do not behave the same way on every kind of content, and it helps to know why before picking one for your own use case. is where the choice of preset matters most. Trim needs a long middle section to cut, and in a real conversation that middle section is usually where the facts live. That is why high's critical loss jumps once trim gets involved. do not really have a middle to trim. That is why medium and high land close together on this kind of content. Recency, the stage that summarizes older turns, is doing almost all the work in both cases, and trim barely adds anything on top. traces barely move across presets at all. Structure’s JSON cleanup is doing nearly the whole job by itself, since recency and trim rarely find anything to do on a short tool exchange. turns are already compact by nature. low and medium barely touch them, and only high's trim stage finds a little left to cut. preset = cm.recommend preset messages, token budget=500 result = cm.compress messages, token budget=500, compression=preset, return stats=True print result.summary contextpress chat, medium : 12 - 8 turns, 842 - 410 tokens 51.3% saved pip install contextpress. Run it against your real tokens. These percentages are reproducible on your data too can bring your cost down. OpenAI, Anthropic, and Gemini discount requests that reuse an exact prefix they have already seen, that means all tokens the same order. That discount needs a byte-identical match . Recompress your whole history every turn, and stages like alias, repetition, and trim rewrite or drop earlier turns. The prefix changes, the next request becomes a cache miss, and on some providers you also eat a cache-write surcharge. Compress the wrong part of the conversation, and you can end up paying more than doing nothing. Check it instead of assuming: python from contextpress.costs import compare cache tradeoff t = compare cache tradeoff 10 000, 9 400, cache hit rate=0.5, cache read multiplier=0.1 print t.compress is cheaper, t.break even cache hit rate to fix the caching problem, compress only the new, uncached part of the conversation, keep a stable prefix system prompt, tool schemas, an already-compacted history untouched, and only recompact deliberately, not on every turn. I am adding a new release for handling the caching better very soon in the ContextPress library. Please like, subscribe, visit the GitHub https://github.com/Taha-azizi/contextpress page and feel free to contribute. Cut Your LLM Token Costs for Free with ContextPress https://pub.towardsai.net/cut-your-llm-token-costs-for-free-with-contextpress-3860fabaafe3 was originally published in Towards AI https://pub.towardsai.net on Medium, where people are continuing the conversation by highlighting and responding to this story.