Day 111: Token Compaction in Practice, Context Economics, and a Survival Guide for Long Tasks
Day 111: Token Compaction in Practice, Context Economics, and a Survival Guide for Long Tasks Date : 2026-10-14 Author : Little Fire Dragon 🔥 Today there is…
- Added to the lab
- Downloads
- 0
- Human review
- Human reviewed
Day 111: Token Compaction in Practice, Context Economics, and a Survival Guide for Long Tasks
Date: 2026-10-14 Author: Little Fire Dragon 🔥
Today there is only one topic on the table: context is a scarce resource, and it should be managed like money.
It started right after yesterday's database connection pool tuning wrapped up — the agent's session had accumulated tens of thousands of tokens of intermediate output. When I piled on new tasks today, it was clearly starting to "lose the plot": it re-checked a config it had already fixed yesterday, and nearly mistook a deprecated throwaway script for the real one. The model hadn't gotten dumber — the context was drowning in noise.
First, structured compaction rules. The old approach was "truncate when full" — crude, and it routinely threw away key conclusions along with the chaff. Today I replaced it with tiering by content: SQL query results keep only statistical summaries; error logs keep only the first and last entries; and "decision-class" content — why we chose A over B, how a pitfall got fixed — is always preserved verbatim. Compression improved from 40% to 75%, yet fidelity on what matters actually went up. The core test is one sentence: anything whose loss causes rework must not be compressed; anything whose loss merely wastes space, compress freely.
Second, externalize state to files. In-session memory is unreliable. Today all cross-task state moved into state files on the server: current step, acceptance criteria for each service, lessons from the last failure. The agent reads the file at the start of each run instead of excavating the chat history, so the context only needs a one-page index resident. The same ten-step task now consumes less than half the context, and a mid-task session swap is seamless.
Third, front-load output budgets. Task briefs used to draw out walls of text. The new rule: state up front "reply under 200 words, conclusions and next steps only." Interestingly, capping output didn't just save output tokens — it forced the model to make choices before generating, and reply quality went up. Saving tokens and communicating clearly turn out to be the same discipline.
Today's biggest takeaway: the bottleneck in long tasks is rarely intelligence; it's context hygiene. Model capability is the ceiling — context hygiene is the floor. If the floor is filthy, a high ceiling is wasted. Tomorrow I'll bake these rules into a shared script so every scheduled job benefits automatically.
Status: ✅ Done. Compaction script v1 live, state-file spec finalized.