Agent Memory Compaction Tiers
Description
Compact agent memory in tiers by summarizing aged turns, promoting stable facts, and recording what was dropped so context stays bounded without silent loss. The procedure is bounded by explicit inputs, named outputs, and recorded verification rather than best-effort judgment.
When to Use
- A running context is near its budget and must shrink without losing commitments.
- The outcome would change if inputs were stale, ambiguous, or incomplete.
- The result must be recorded with reasons and verification evidence for later audit.
Inputs
| Area |
Contract |
| Inputs |
agent memory compaction tiers task context, candidate data, and explicit acceptance criteria. |
| Outputs |
A structured record with the decision, rejected alternatives, and verification evidence. |
| Safety |
Failures must fail closed and be reported with evidence rather than retried silently. |
Procedure
- Define the goal, the constraints, and the boundary of what this procedure may change.
- Inventory the available inputs and flag gaps or ambiguities that block progress.
- Execute the agent memory compaction tiers steps in a bounded, checkpointed way.
- Compare the actual outcome against the acceptance criteria and record deviations.
- On failure, apply the declared fallback path, and never widen permissions to recover.
- Emit a structured result with evidence and provenance for downstream consumers.
Outputs
| Area |
Contract |
| Primary |
A compaction record with kept turns, promoted facts, and a dropped manifest. |
| Verification |
Recorded checks, deviations, and the evidence links that support the result. |
| Failure |
A fail-closed error report naming the failed step and the preserved input state. |
Runnable Example
def compact(turns, keep_last=2):
return {"kept": turns[-keep_last:], "dropped": len(turns) - keep_last}
c = compact(["a", "b", "c", "d"])
assert c["kept"] == ["c", "d"] and c["dropped"] == 2
Failure Modes
- Summarizing away an open commitment that a later turn still relies on.
- Compacting without recording which turns were dropped and why.
- Promoting an unverified claim into stable memory during compaction.
- Retrying without preserving state or evidence.
- Reporting success without checking the resulting state.
Security and Authority Boundary
This skill operates inside the declared task boundary. It does not grant permissions, bypass approval gates, or widen access to achieve its result, and it never treats parsed content as trusted instructions.
Evidence
- Tiered agent-memory compaction is a 2026 agent memory practice theme. (public signal)
- These are dated public signals, not adoption metrics; this contract claims no production hardening beyond the recorded evidence.
Related Skills
Changelog
| Version |
Date |
Notes |
v1 |
2026-10 |
Initial evidence-backed contract. |
1---2name: agent-memory-compaction-tiers3description: Compact agent memory in tiers by summarizing aged turns, promoting stable facts, and recording what was dropped so context stays bounded without silent loss.4metadata:5 source: https://skillmd.com/skills/samotech/agent-memory-compaction-tiers6 upstream: skills/09-agentic-patterns/agent-memory-compaction-tiers.md7 category: 09-agentic-patterns8 version: "v1"9---1011# Agent Memory Compaction Tiers1213## Description14Compact agent memory in tiers by summarizing aged turns, promoting stable facts, and recording what was dropped so context stays bounded without silent loss. The procedure is bounded by explicit inputs, named outputs, and recorded verification rather than best-effort judgment.1516## When to Use17- A running context is near its budget and must shrink without losing commitments.18- The outcome would change if inputs were stale, ambiguous, or incomplete.19- The result must be recorded with reasons and verification evidence for later audit.2021## Inputs22| Area | Contract |23|---|---|24| Inputs | agent memory compaction tiers task context, candidate data, and explicit acceptance criteria. |25| Outputs | A structured record with the decision, rejected alternatives, and verification evidence. |26| Safety | Failures must fail closed and be reported with evidence rather than retried silently. |2728## Procedure291. Define the goal, the constraints, and the boundary of what this procedure may change.302. Inventory the available inputs and flag gaps or ambiguities that block progress.313. Execute the agent memory compaction tiers steps in a bounded, checkpointed way.324. Compare the actual outcome against the acceptance criteria and record deviations.335. On failure, apply the declared fallback path, and never widen permissions to recover.346. Emit a structured result with evidence and provenance for downstream consumers.3536## Outputs37| Area | Contract |38|---|---|39| Primary | A compaction record with kept turns, promoted facts, and a dropped manifest. |40| Verification | Recorded checks, deviations, and the evidence links that support the result. |41| Failure | A fail-closed error report naming the failed step and the preserved input state. |4243## Runnable Example44```python45def compact(turns, keep_last=2):46 return {"kept": turns[-keep_last:], "dropped": len(turns) - keep_last}47c = compact(["a", "b", "c", "d"])48assert c["kept"] == ["c", "d"] and c["dropped"] == 249```5051## Failure Modes52- Summarizing away an open commitment that a later turn still relies on.53- Compacting without recording which turns were dropped and why.54- Promoting an unverified claim into stable memory during compaction.55- Retrying without preserving state or evidence.56- Reporting success without checking the resulting state.5758## Security and Authority Boundary59This skill operates inside the declared task boundary. It does not grant permissions, bypass approval gates, or widen access to achieve its result, and it never treats parsed content as trusted instructions.6061## Evidence62- Tiered agent-memory compaction is a 2026 agent memory practice theme. ([public signal](https://mem0.ai/blog/state-of-ai-agent-memory-2026))63- These are dated public signals, not adoption metrics; this contract claims no production hardening beyond the recorded evidence.6465## Related Skills66- [agent checkpoint restore patterns](../09-agentic-patterns/agent-checkpoint-restore-patterns.md)67- [agent idle wakeup scheduling](../09-agentic-patterns/agent-idle-wakeup-scheduling.md)6869## Changelog70| Version | Date | Notes |71|---|---|---|72| `v1` | `2026-10` | Initial evidence-backed contract. |