Open-source standard · v0.1.0
Compact the context. Keep the evidence.
An open-source standard for assisting agents in managing their compactation strategy with the model or models they are using. Capture raw evidence first, derive compact projections with declared losses, verify before use, and rehydrate exact bytes before writing any consequential claim.
- Content-addressedRecord IDs are SHA-256 of exact bytes, never agent-chosen labels.
- Append-onlyThe ledger keeps every earlier event as a prefix. No silent rewrites.
- Coverage balancesCaptured bytes equal projected bytes plus every declared omission.
- Verified rehydrationReport claims cite restored records, or they are UNVERIFIED.
curl -fsSL -O https://raw.githubusercontent.com/awdemos/compactation/v0.1.0/COMPACTATION.md
The failure we fixed
A 37 percent saving with no way back
On 2026-11-25 an agent compacted noisy logs mid-task. Estimated tokens fell by roughly 37 percent. The originals were discarded before the bug was fixed. When the full report came due, the compacted text could not stand in for the lines that proved the diagnosis.
Compact
Noisy logs became a shorter summary. The estimate looked good and the context pressure dropped.
Discard
The source bytes were thrown away. The summary became the only remaining account of the run.
Reconstruct
The report needed verbatim evidence. There was no record to restore and no citation to make.
Expectation, not a measured result
We expect agents using the standard to gain roughly 37 percent better-than-average session-management success. That figure comes from an initial trial with no control group. It is UNVALIDATED and needs more data. See the validation plan.
The contract
Seven rules, stable across models
A repo drops COMPACTATION.md at its root, alongside AGENTS.md or CLAUDE.md. Repos may add rules but cannot remove these seven.
Capture before compacting
Store immutable, content-addressed bytes before deriving any compact view.
Project, do not rewrite
Active context is a cache. A projection has references, coverage, and declared losses.
No silent loss
Every omission names a policy, a reason, and the records it affects. The rest are retained.
Rehydrate before deciding
Fixes, gates, and reports cite restored records. A summary alone is UNVERIFIED.
Verify before use
Recompute hashes, resolve references, balance coverage. Invalidate on mismatch.
Budget and exit
Exit on green, an enforced budget, or a stall. Escalate a stall to the human.
Report with provenance
Show the ledger, the estimator, the omissions, and the validation status of every figure.
How it works
An evidence chain you can check
The operations contract is small enough to implement in an afternoon and strict enough to audit.
Built for the models you use
Each projection records the model family, estimator, and policy. Provider compaction is logged as context state, not treated as an evidence operation. After a model switch, projections are re-derived and references verified.
Honest about what it cannot do
Markdown does not enforce budgets, triggers, or kill switches. Those are runtime capabilities. If a mechanism is missing, the agent discloses it and reduces the autonomy it claims.
Reference implementation
A ledger, not string surgery
The dependency-free Python CLI implements every operation in the contract. It exists because letting agents manage their own memory by manipulating strings is not great either.
capture python3 tools/compactation.py capture --file noisy.log --kind log project python3 tools/compactation.py project --policy policy.json --out projection.json verify python3 tools/compactation.py verify --projection projection.json retrieve python3 tools/compactation.py retrieve --id <record-id> --out evidence.bin report python3 tools/compactation.py report --projection projection.json --claims claims.json
| Guarantee | Where it is enforced |
|---|---|
| Identical bytes make one record | sha256(bytes) is the ID; capture is idempotent |
| Hash failure is an error | retrieve and verify refuse tampered objects |
| Redaction never edits the source | Policy applies only inside the projection |
| Uncited claim is UNVERIFIED | report validates each claim against the ledger |
| Secrets are not silently stored | Capture refuses common secret-like patterns without a reason |
22 unit tests and an end-to-end noisy-log demo ship with the tool. Token estimates use a named utf8_bytes_over_4 heuristic; they are estimates, not tokenizer output.
Evidence and governance
Published like a standard, not a blog post
Every rule has a destination
The traceability matrix maps each contract rule to a CLI command, a skill instruction, or an explicitly external runtime requirement. It also records the 37 percent expectation as unvalidated.
Signed tags and checksums
Every release is tagged and signed. Verify with git tag -v v0.1.0. SHA-256 checksums for tracked files are in the changelog, and an SPDX SBOM is published.
Independent challenges
This repo holds itself to ADVERSARIAL_REVIEW.md: one lens at a time, evidence-backed findings, and a challenger that disputes weak ones.
Issues first, verified commits
Every PR links an accepted issue. Every commit on main is signed. Every merge has NCO signoff from a reviewer who did not author the change.
FAQ
Common questions
Is this the same as my runtime's automatic compaction?
No. Provider compaction is an external context-window event. This standard governs the agent's own evidence lifecycle: what is captured, how a projection is derived, and what must be rehydrated before a claim is made. The two can interact, but they are not the same operation.
Does it really give 37 percent better session success?
That is an expectation from an initial trial, not a measured result. There was no control group. The claim is marked UNVALIDATED everywhere it appears, and the validation plan defines the experiment that would settle it.
Why not just let the agent rewrite its notes?
Because a rewritten note is a hypothesis about the evidence, not the evidence. It cannot prove what it omitted, cannot be checked against the original, and cannot be trusted after a model switch. The standard keeps the original and makes the derived view auditable.
Do I need the Python tool to follow the standard?
No. The skill instructs the agent directly. Without the tool, storage and hashing are session-only and must be disclosed. The tool supplies durable, deterministic operations; it does not supply enforced budgets or triggers.
What about secrets in logs?
The CLI refuses capture when it detects common secret-like patterns unless an explicit reason is given, and default redaction replaces synthetic tokens inside projections. Stored bytes are never rewritten by a policy. Real credentials do not belong in public fixtures or issues.