# Memory Summarization Techniques

> Use when long agent transcripts, logs, or episodic records must be compressed into durable memory without losing decisions, evidence, or open questions. Covers extractive versus abstractive summarization, hierarchical rolling summaries, decision and evidence preservation rules, summary validation checks, and refresh triggers, with scoring terms for memory summarization, context compression, rolling summaries, and episodic consolidation.

- Skill: `mizazhaider-ceh/memory-summarization-techniques` (Agent Skill)
- Install (CLI): `npx get-skill add mizazhaider-ceh/memory-summarization-techniques`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mizazhaider-ceh/memory-summarization-techniques/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: mizazhaider-ceh (https://skillmd.com/u/mizazhaider-ceh)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/mizazhaider-ceh/memory-summarization-techniques

---


Summarization is how episodic memory becomes durable memory without
growing forever. A raw transcript is too long to keep and too noisy to
recall from, but a careless summary drops the decision, keeps the
chat, and invents a conclusion nobody reached. This sub-skill covers
summarization as an engineering step inside the memory architecture
defined by its parent, ../../SKILL.md, meaning which technique fits
which input, what a summary must preserve, and how to check that it
did. It builds on ../../../memory-consolidation/SKILL.md, which covers when
consolidation runs, and adds the how of the summary itself.

## Quick Workflow

1. Pick the technique from section 1 based on input length and risk.
2. Extract decisions, evidence, and open questions before writing
   any prose, using the preservation checklist in section 2.
3. Write the summary from the extracted items, not from memory of
   reading the transcript.
4. Run the validation checks in section 3, and reject summaries that
   add claims or drop decisions.
5. Store the summary with links to its source records, and set a
   refresh trigger for when those sources change.
6. On refresh, summarize the delta, not the whole history again.

## 1. Choosing a technique

Extractive summarization selects sentences or records verbatim. It
never invents wording, which makes it the safest choice for evidence
and for anything that will be quoted later. Its weakness is
readability, because selected fragments do not always read as a
coherent story. Abstractive summarization rewrites in fresh prose.
It reads well and compresses harder, but it can drift, inventing
connections the sources never made. Hierarchical summarization
summarizes chunks first, then summarizes the chunk summaries, which
is the only practical approach for inputs far larger than the
working context.

```python
"""Technique selection: input size and risk decide the method."""

def choose_technique(record_count, contains_decisions, will_be_quoted):
    if will_be_quoted:
        return "extractive"
    if record_count > 200:
        return "hierarchical"
    if contains_decisions:
        return "extractive_then_abstractive"
    return "abstractive"

# extractive_then_abstractive means decisions and evidence stay verbatim
# while background narrative is rewritten, which keeps the risky parts
# exact and the rest readable.
```

Decision guide:

- Evidence, quotes, commands, outputs, and error messages stay
  extractive. Always. A paraphrased error message is a different
  error message.
- Background narrative and reasoning flow may be abstractive, but
  only after the extractive items are locked in.
- Anything over roughly 200 records goes hierarchical, with chunk
  summaries stored alongside the final summary so a later reader can
  drill down without re-reading the raw input.
- If the summary will feed a graded report or an incident timeline,
  use extractive, and let a human rewrite the narrative.

## 2. What a summary must preserve

A summary that drops the decision is worse than no summary, because
it looks complete while hiding the one thing the next agent needs.
The preservation template below is the contract every summary in
this store must satisfy, whatever the technique.

```yaml
# summary-contract.yaml - required sections of every stored summary
required_sections:
  decisions:
    description: choices made, who made them, and when
    format: one line per decision, verbatim where possible
  evidence:
    description: observations and results the decisions rested on
    format: record ids plus short verbatim excerpts
  open_questions:
    description: questions left unanswered, with owners if known
    format: one line per question, never silently dropped
  rejected_options:
    description: options considered and rejected, with the reason
    format: one line per option, because re-trying dead ends wastes time
forbidden_in_summaries:
  - claims with no source record
  - confidence upgrades, meaning a guess restated as a fact
  - merged attributions, meaning two agents claims combined into one
```

The rejected-options section is the one teams skip first and regret
most. Without it, the next agent re-runs the dead end, re-reads the
same evidence, and reaches the same rejection, paying the full cost
again. The open-questions section plays the same role for unfinished
work, turning a summary from a closed story into a handoff.

## 3. Summary prompts and validation checks

A summarization prompt must name the contract, or the summarizer
will optimize for brevity and fluency instead of preservation. The
prompt below is written for a language model summarizer, but the same
rules apply to a human summarizer, and the validation checks after
it apply to both.

```
Summarize the attached agent records into a durable memory entry.
Follow the summary contract exactly, with four sections in order:
Decisions, Evidence, Open questions, Rejected options.
Rules:
- Copy decisions, commands, error messages, and numbers verbatim.
- Every factual claim must cite a source record id from the input.
- Do not add conclusions, causes, or motives that no record states.
- Do not drop an open question. If it is unresolved, say so.
- If two records contradict each other, report both, do not pick one.
- Keep the summary under 500 words unless the evidence section needs more.
```

```python
"""Summary validation: reject summaries that invent or drop content."""

import re

def validate_summary(summary, source_ids, decisions):
    problems = []
    cited = set(re.findall(r"mem_\d+", summary))
    unknown = cited - set(source_ids)
    if unknown:
        problems.append("cites unknown records: " + ", ".join(sorted(unknown)))
    for decision in decisions:
        if decision not in summary:
            problems.append("dropped decision: " + decision)
    for section in ["Decisions", "Evidence", "Open questions",
                    "Rejected options"]:
        if section not in summary:
            problems.append("missing section: " + section)
    return problems

# An empty problems list means the summary passes. Any problem means
# the summary is rejected and regenerated, not patched by hand, so the
# failure is visible in the summarization log.
```

Validation rules:

- A summary that cites a record outside its source set is rejected,
  because the citation is either invented or pulled from the wrong
  context.
- A summary that drops a decision is rejected, even if it reads
  beautifully, because readability is not the contract.
- A summary that upgrades confidence, turning "possibly" into a flat
  statement, is rejected on review, and the pattern is logged so the
  prompt can be tightened.

## 4. Rolling summaries and refresh triggers

A rolling summary is updated as new records arrive, instead of being
rebuilt from scratch. The update summarizes the new records and
merges them into the existing summary, preserving decisions and open
questions, and closing questions the new records answer. Refresh
triggers keep rolling summaries honest, and they are:

- A new decision on the same topic, which always triggers a refresh.
- A contradiction with an existing summary claim, which triggers a
  review, not a silent overwrite.
- A fixed interval, such as 30 days, for summaries of ongoing work.
- A request for the summary itself, which is a cheap moment to check
  whether it still matches its sources.

```sql
-- Find summaries whose source records changed since the summary was made
SELECT s.id AS summary_id, s.topic, COUNT(r.id) AS changed_sources
FROM memory_summaries s
JOIN memory_records r ON r.topic = s.topic
  AND r.updated > s.created
GROUP BY s.id, s.topic
ORDER BY changed_sources DESC;
```

Never refresh by appending raw new text to the old summary. Appending
grows the summary without bound and preserves contradictions side by
side. Merge properly, resolve or report contradictions, and keep the
previous version for audit, so a bad merge can be rolled back.

## Edge cases

- The input is mostly noise with one decision. The summary is short
  and mostly that decision, and that is correct. Padding it to look
  substantial adds invented content.
- Two records contradict each other. Report both with their sources
  and dates, and mark the topic disputed. Picking a winner in a
  summary hides a real disagreement.
- The summarizer hits its own context limit. Switch to hierarchical
  summarization, and store chunk summaries, rather than truncating
  the input silently and summarizing a partial history.
- A summary is quoted elsewhere. Refreshing it does not update the
  quotes, so link quotes to the summary version, not just the topic,
  and note superseded versions clearly.
- Summarization is slow or expensive. Summarize on consolidation
  triggers, such as session end or record count thresholds, not on
  every write, and skip inputs with no decisions and no open items.

## Key references

- CWE-200 (Exposure of Sensitive Information to an Unauthorized
  Actor): why summaries need the same scope as their sources.
- SQLite documentation: https://sqlite.org/docs.html
- Python sqlite3 module: https://docs.python.org/3/library/sqlite3.html
- ../../SKILL.md and ../../../memory-consolidation/SKILL.md in this
  repo.

