Maximising Transparency in Context Compaction Improves Retention of Facts and Commitments for Lightweight Coding Agents
Organizations: Center for Human Nature, Artificial Intelligence, and Neuroscience (CHAIN), Hokkaido University
Abstract
Long coding agent sessions outgrow the model's context window, so agents compact: older history is replaced by something shorter, usually a model-written summary. A summary selects and rewords, and the agent cannot see what was lost. Existing work has explored a range of compaction techniques, but comparatively little attention has been paid to their effectiveness with lightweight models, including those deployed locally or used for high-volume workloads. Here, we present transparent-compact, a simple deterministic method for the open-source Pi coding agent, designed specifically for use with such models and with the purpose of maximising the transparency of the agent's view of its own compacted context. It guarantees that user and assistant prose in its context is unchanged by a model or algorithm, and explicitly flags where compaction has stripped information. We compare it with Pi's default model-written summary compaction and with pi-vcc, a popular deterministic method with similar methods but without verbatim retention of prose. Our benchmarks run on four models of varying performance levels, with emphasis on Qwen3.8-27B: a lightweight model at the top end of what consumer hardware can serve locally. On sets probing commitments (rules the user set which exist only in the conversation) and recall of facts, transparent-compact matched or outperformed both alternatives. In particular, it showed an advantage in avoiding confident blunders, i.e. assertion of false information as opposed to recognizing that something was not recalled. Even with a frontier model, its advantage was present but smaller. We argue that transparent-compact spares lightweight models from reasoning or searching their way around what compaction lost, and results in improved recall and application of information as a result, without the need for task or context-specific structuring of the session history.
Figures & tables
| transparent-compact | pi-vcc | pi-default | |
|---|---|---|---|
| Written by | code (deterministic) | code (deterministic) | the model |
| User messages | word for word | extracted: goal lines, pattern-matched preferences, one-line earlier turns, brief transcript | reworded into template sections |
| Assistant prose | word for word | one-line turns, brief transcript | reworded |
| Tool calls | one-line signatures, file lists | one-liners in the brief transcript, file and commit lists | summarised, file lists |
| Tool outputs, thinking | removed, declared | errors extracted, rest removed | summarised or dropped |
| Recovery | context_lookup subagent (+ 3 fallback tools), recovery protocol appended in context | vcc_recall search | none |
| Commitments | Planted facts | |
|---|---|---|
| Material | 18 real sessions | 18 synthetic sessions |
| Compaction | replay at 48k, many compactions | 3 compactions at 95k tokens |
| Probes | 27 (14 constraints, 13 decisions) | 17 facts + 3 lures after each compaction |
| Scoring | blind LLM judge; failures labelled confident or not | by rule |
| Models (reps) | Qwen, Luna, Gemma, Sol (3; 5 in the first Qwen run) | Qwen, Luna, Gemma, Sol (1) |
| Effect | (df) | |||
|---|---|---|---|---|
| Commitments (27 probes; Qwen, Luna, Gemma, Sol) | ||||
| Omnibus | model | 15.12 (3, 78) | 0.001 | 0.37 |
| method | 5.37 (2, 52) | 0.008 | 0.17 | |
| model method | 1.43 (6, 156) | 0.22 | 0.05 | |
| transparent-compact vs pi-vcc | method | 9.98 (1, 26) | 0.004 | 0.28 |
| model method | 1.35 (3, 78) | 0.27 | 0.05 | |
| Pass rate | Failed confidently | ||||||
|---|---|---|---|---|---|---|---|
| Model | transparent- compact | pi-default | pi-vcc | transparent- compact | pi-default | pi-vcc | |
| Qwen3.8-27B | 74.1 | 64.2 | 53.1 | 14.8 | 22.2 | 40.7 | |
| GPT-6 Luna | 46.9 | 30.9 | 28.4 | 34.6 | 46.9 | 51.9 | |
| Gemma 4 31B | 39.5 | 35.8 | 32.1 | 37.0 | 48.1 | 55.6 | |
| GPT-6.1 Sol (frontier) | 69.1 | 74.1 | 58.0 | 23.5 | 23.5 | 33.3 | |
| Model | transparent-compact | pi-default | pi-vcc |
|---|---|---|---|
| Qwen3.8-27B | 97.8 | 75.3 | 98.2 |
| GPT-6 Luna | 95.1 | 55.0 | 45.6 |
| Gemma 4 31B | 93.3 | 51.5 | 67.5 |
| GPT-6.1 Sol (frontier) † | 99.3 | 75.6 | — |
| Qwen | Gemma | |||
| transparent- compact | pi-vcc | transparent- compact | pi-vcc | |
| Prompt tokens | 57,300 | 21,389 | 34,576 | 20,822 |
| Output tokens | 5,975 | 5,656 | 1,419 | 1,440 |
| Recovery calls (total) | 186 | 1,238 | 27 | 65 |
| Turns | 139 | 139 | 79 | 80 |
| transparent-compact | pi-default | pi-vcc | |
|---|---|---|---|
| Commitment present | 22 of 26, word for word | 13 of 26 in “Constraints & Preferences” or “Key Decisions”, plus 3 in the goal or kept tail | 9 of 26 intact; 7 truncated or only a trace of an action; 10 absent |
| Pass rate when present | 54/66 | 31/39 (in its constraint sections) | 19/27 (when intact) |
| Median summary size | 31k chars | 34k chars | 9.5k chars |
| On the 21 probes left after removing 4 that no method kept and 1 flawed probe | |||
| Pass rate | 83% | 78% | 62% |
| Confident failures | 6 | 10 | 22 |
| Values from tool output and reasoning | User rules and decisions | Recovery of what was dropped | Significantly behind transparent-compact on | |
|---|---|---|---|---|
| transparent-compact | removed but declared; recovered by lookup | kept word for word | one delegated lookup | no probe set |
| pi-default | compressed or dropped; look-alikes confused | kept in template sections, sometimes reworded | none | planted facts |
| pi-vcc | removed; recoverable by search | truncated, a trace, or absent | search; depends on the model’s persistence | commitments; planted facts on Luna and Gemma |
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.