Coding / AI Engineering / Context Engineering / billion-context
CHAPTER 09 / 11 · CONTEXT ENGINEERING
Compression Doctrine
A prompt-based policy for compression judgment
Compression Doctrine is not a separate algorithm or classifier. In the implementation, it is a set of prompt rules that teaches the model how to judge compression: when information has finished its job, what must survive, what can disappear, and what to prioritize when space is tight.
VISUAL STUDY / TASK-RELATIVE JUDGMENT
Compress information when it has finished its job.
ONE SEMANTIC QUESTION
Has this information
finished its job?
Judge it relative to the current task step.
- 01Still directly needed?
Keep the information raw in the working context.
- 02No longer directly needed?
It has been consumed and can become a fold candidate.
- 03Then preserve what survives.
Keep the result, constraints, exact load-bearing details and source references.
THE NOTEBOOK
Concise learning notes · source-grounded mechanismsCompression Doctrine is a prompt
At the implementation level, Compression Doctrine is a prompt-based policy. The core rules live in compression-rules.ts and are injected into the model through the compression system prompt. They do not compute a relevance score or run a separate classifier; they instruct the model how to make the judgment itself.
1. When should information be compressed?
Ask whether the information has finished its job for the current task step.
If the model still needs to directly use it, keep it raw. If not, it becomes a compression candidate.
This is why age alone is not the criterion:
- old but still needed → keep
- recent but already consumed → compress
2. What must survive?
Preserve the information that future work may still depend on:
- goals and user intent
- constraints
- decisions and rationale
- exact load-bearing technical details
- open objectives, questions, and TODOs
- message refs when source recovery may be needed
3. What can disappear?
Drop the vessel after extracting the signal. Typical examples include:
- verbose logs once the error or result is captured
- duplicate reads
- consumed exploration
- intermediate discussion and self-correction
- repeated status checks
Dead ends can disappear too, but their lesson should survive in compact form: tried X, failed because Y.
4. When space is tight
Preserve in this order:
- Goal / intent / constraints
- Decisions + rationale
- Exact technical artifacts
- Conclusions / findings
- Lessons learned
In short:
When? Has it finished its job?
Keep? Preserve what future work depends on.
Drop? Remove consumed process after extracting the signal.
Prioritize? goal → decisions → artifacts → conclusions → lessons.
CHECK YOUR INTUITION
What is Compression Doctrine in the implementation?
Choose an answer to reveal the reasoning.
FOLLOW THE SOURCE
Reviewed source: billion-context 0.1.180 / 03d27f9. The notes are Lawson’s learning interpretation of the reviewed repository.