Context compression on route-to-local (truncate older turns + shell-output tails) #87
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Motivation
Small local models have a smaller EFFECTIVE context window than their advertised one — quality degrades well before the token cap. The most expensive parts of the typical aish context are (a) old turns the model doesn't need and (b) shell-exec output blocks that are mostly noise after the last 30 lines.
Routing-aware context compression: when a request is about to fire against a LOCAL model preset, run a
compress_for_local(turns)filter that keeps last N turns and tails long tool/exec content. Cloud routes get the full context unchanged.Proposal
In
context.lua(or alongside broker call site in repl.lua):Wiring: when the routed model is in a
cfg.routing.local_compress_classesset (or any model markedmodel_cfg.local_compress = true), the messages array sent to broker.chat_stream is compressed first. Cloud models bypass.Constraints
helpers.skip_compress.summarize_on_evictalready does something similar but over the WHOLE session; this is per-request compression for one specific broker call.Estimate
~2 hours. Touches
context.lua(the compressor) +repl.lua(route-aware call site).Source
Architecture analysis (2026-05-16). Listed as "medium-high" gain.