TokenPad
Building

Agent Memory Compaction Prompt

Turn a growing transcript into a compact state artifact.

Facts established so far, one per line

229 characters5 lines0 tokensor drop a file

Memory SummarizerExact
0Token change
Token change0no change
Input tokens0what you pasted
Output tokens0what you would send
Token cost of this result
Output tokens0
As input$0.00
× 100K requests$0.00

Everything on this page runs in your browser. Nothing you paste is transmitted, because there is no server here to transmit it to.

Result
 

Why compaction beats truncation

A long-running agent eventually exceeds either its budget or its context window. Truncating the oldest turns is the obvious fix and loses exactly the wrong things — the decisions and constraints established early are usually the ones that still matter.

Compaction preserves the conclusions and discards the reasoning that produced them, which is a far better trade at the same token cost.

The rules that make it work

Keep decisions, constraints, measured values and anything the user asked you to remember. Drop pleasantries, restatements, and reasoning that led to a decision already recorded.

Preserve numbers and identifiers verbatim. A summariser that rounds a measurement or paraphrases an identifier has destroyed the thing the summary existed to carry, and the loss is invisible until something downstream fails.

Frequently asked questions

When should compaction run?
On a threshold rather than a schedule — when the accumulated history passes a share of the window, typically half to two thirds. Running it too often costs a model call each time and loses detail for nothing.
Does compaction cost money?
Yes, one model call. It pays for itself almost immediately, because every subsequent request carries the compact state instead of the full transcript.

More building tools