May 2, 2026
Closing Out Compaction, Opening Rich Media
The compaction rewrite gets its last bug fixes and a 2,000-test cleanup, while a new spec starts taking shape for tool results that render as real UI instead of text.
Yesterday’s compaction rewrite landed the architecture. Today was about proving it holds under the cases that actually break things — and then clearing the decks so the next big idea has clean ground to build on.
The bug was subtle and the kind that only shows up in production shape: the code that decides “are we about to run out of context, better summarize” was only measuring the user’s message, not the full payload the model actually receives. A 128K-token context window gives you roughly 102K tokens of headroom before compaction should kick in, but the system prompt and tool schemas — which can be a meaningful chunk of that budget — were being assembled after the check ran. So the threshold check was comparing against a number that was structurally too small, and compaction could get silently skipped even when the real request was over budget. The fix makes every provider serialize the exact request body it’s about to send — not an approximation — and measures tokens against that. One code path, one truth: what gets measured is what gets sent.
Fixing that surfaced a second bug, the more dangerous kind: an infinite loop. Once compaction ran and reset the iteration counter, the threshold check fired again immediately — because compaction shrinks the conversation body but doesn’t touch the system prompt or tool schemas, and those alone could still trip the same threshold. Without a guard, that’s a hang. The fix is a one-shot flag: compact once per turn, and if the threshold is still tripping after that, log it and send anyway — with the existing oversized-payload fallback as the final backstop. Two real end-to-end flows that were failing now pass, verified with a test that exercises the whole loop for real: real database, real compaction call, real retry — not a mock standing in for the hard part.
With the fix proven, the day pivoted into cleanup. A large slice of the test suite covering already-deleted subsystems got removed rather than left to rot — dead tests are worse than no tests, they cost review time and tell you nothing. In their place: real feature tests for services that had shipped without coverage, including the salience scoring and metrics aggregation that quietly power how Chalie prioritizes what it remembers. Net effect: thousands of lines of stale test code gone, meaningful coverage added, full suite green.
The rest of the day went to a sweep most users will never notice directly but that pays for itself constantly: nearly 250 static-analysis findings resolved across the codebase — unused code paths trimmed, error logging hardened against injection, duplicate error strings consolidated into single sources of truth, and a batch of frontend modernization passes. None of it changes what Chalie does. All of it reduces the number of ways it can quietly do the wrong thing later.
And one thread got planted that’s worth watching: the first spec pass for tools that render actual UI in the chat instead of plain text — a weather tool answer showing a real weather card, not a paragraph describing the temperature. It’s spec-only today, reconciling how the answer gets tagged and rendered without breaking anything already in place, but it’s the seed of a chat interface that shows you things instead of just telling you things.
Highlights
-
Fixed a real bug where compaction measured only the user’s message, not the full request — meaning it could silently skip triggering even when the actual payload was over budget
-
Fixed a compaction infinite-loop risk with a one-shot per-turn guard, verified against the two end-to-end flows that were failing
-
Removed thousands of lines of dead tests for already-retired subsystems, replaced with real coverage for salience scoring and metrics
-
Resolved roughly 250 static-analysis findings across backend and frontend — safer logging, less duplication, modernized JS
-
First spec pass landed for tool results that render as UI cards in chat, starting with weather