Logo von Memory Consolidation

Memory Consolidation

Community
AnthonyAlcaraz
memory-consolidation

Consolidation pipeline — turn noisy raw episodes into durable knowledge (Agentic GraphRAG Ch4, Example 4-5 + Example 4-13). Four steps: cluster related episodes by topic, summarize each cluster into one consolidated fact, create the consolidated node, and maintain a provenance chain back to the source episodes so "how do you know that?" is answerable. Clusters below a minimum size (default 3) are skipped — not enough examples to generalize. Adds the sleep-time-compute discipline: run consolidation during idle periods, never on the synchronous response path, and pre-compute inferences that anticipate likely queries. Use when an agent accumulates redundant, overlapping experiences that must compress into stable, queryable patterns. NOT for one-shot agents (nothing to consolidate), NOT for the response hot path (consolidation is a background/idle job), NOT for facts that must stay individually addressable (consolidation merges them).

Übersicht

HerausgeberAnthonyAlcaraz
Repositoryagentic-graph-rag-skills
Skill-Namememory-consolidation
Sterne
29
Forks
9
Mitgelieferte Dateien
2
LizenzMIT
Links
  • Anweisungen in Markdown

    Eine SKILL.md-Datei, die das Modell bei Bedarf lädt. So werden nur dann Token verbraucht, wenn eine Anfrage tatsächlich dazu passt.

  • Funktioniert mit jedem LLM

    KI-Skills bestehen aus reinem Markdown, nicht aus anbieterspezifischem Code. Daher funktionieren sie mit GPT, Claude, Gemini, Grok oder einem lokalen Modell.

  • Mitgelieferte Dateien: 2

    Skripte, Vorlagen und Referenzmaterial, die das Modell bei der Arbeit lesen kann. Die Dateien sind schreibgeschützt und werden niemals ausgeführt.

  • Open Source

    Von AnthonyAlcaraz auf GitHub veröffentlicht. Prüfen Sie vor der Installation die Quelldateien.

Installation

Installieren Sie den KI-Skill Memory Consolidation in TypingMind, um ihn mit jedem LLM zu nutzen, oder fügen Sie ihn einem anderen Agenten hinzu, der SKILL.md lesen kann.

1

In TypingMind installieren

TypingMind installiert einen Skill direkt aus seinem GitHub-Ordner. Dabei liest die App SKILL.md, bündelt die Ressourcendateien und speichert das Ergebnis lokal.

  1. Öffnen Sie die App und gehen Sie zu Plugins → Skills.
  2. Wählen Sie „Von GitHub installieren“.
  3. Fügen Sie die unten angegebene URL des Skill-Ordners ein und bestätigen Sie.
    https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/memory/memory-consolidation
  4. Aktivieren Sie den Skill in jedem Chat, in dem er verfügbar sein soll.
Plugins → Skills → Skill hinzufügen → Über GitHub-URL. Fügen Sie dann die Ordner-URL ein und klicken Sie auf „Weiter“.
2

In einem anderen Agenten installieren

Jeder Agent, der das Agent-Skills-Format unterstützt, kann diesen Skill nutzen. Kopieren Sie den Ordner in das Skill-Verzeichnis des jeweiligen Agenten.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills.git /tmp/agentic-graph-rag-skills
mkdir -p .claude/skills
cp -r /tmp/agentic-graph-rag-skills/skills/memory/memory-consolidation .claude/skills/memory-consolidation
Starten Sie Claude Code nach dem Kopieren neu, damit der neue Skill erkannt wird.

In TypingMind verwenden

Aktivieren Sie Memory Consolidation in einem beliebigen Chat in TypingMind. Den Rest übernimmt das Modell. Name und Beschreibung des Skills stehen im System-Prompt. Sobald eine Anfrage passt, lädt das Modell selbstständig die vollständigen Anweisungen — Sie müssen den Skill nie manuell aufrufen, und er verbraucht erst Token, wenn er tatsächlich genutzt wird.

Das Modell lädt Memory Consolidation automatisch, sobald eine passende Anfrage gestellt wird.

Funktioniert mit jedem KI-Modell

KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher ist Memory Consolidation nicht an das Modell gebunden, für das der Skill geschrieben wurde. Installieren Sie ihn einmal in TypingMind und nutzen Sie ihn mit GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder einem selbst betriebenen lokalen Modell — alles mit Ihren eigenen API-Schlüsseln.

  • Wird nur bei Bedarf geladen

    Der System-Prompt enthält nur den Namen und die Beschreibung. Die Anweisungen werden bei der ersten passenden Anfrage geladen. Ein ungenutzter Skill verursacht daher keine Kosten.

  • Modell im laufenden Chat wechseln

    Da der Skill aus Anweisungen statt aus Code besteht, funktioniert er auch nach einem Modellwechsel — das nächste Modell liest dieselbe SKILL.md-Datei.

Skill-Anweisungen

Dies ist der Inhalt von SKILL.md, den das Modell lädt. Lesen Sie ihn vor der Installation — ein Skill besteht aus Anweisungen, denen Ihr Modell folgt.

Memory Consolidation

Overview

Your agent accumulates many interactions, but most are redundant, overlapping, or partially inconsistent. Consolidation is the agent's "sleep phase": it compresses short-term experiences into long-term understanding. Ch4 frames this as four steps (Example 4-5):

  1. Cluster related memories (cluster_by_topic) — group conversations about the same project/incident by similarity.
  2. Summarize each cluster (summarize_cluster) — replace "Monday: deadline Friday; Tuesday: confirmed Friday; Wednesday: Friday again" with one fact: "Project deadline: Friday (confirmed 3 times)". Meaning preserved, redundancy gone.
  3. Consolidate into permanent graph nodes (create_consolidated_memory).
  4. Maintain provenance (maintain_provenance_chain) — keep the DERIVED_FROM links so the agent can trace a belief back to the exact interactions that produced it.

Two disciplines from the chapter shape the implementation:

  • Minimum cluster size (Example 4-13: "Need enough examples to generalize"). A pattern derived from a single episode is not a pattern. Default minimum is 3.
  • Sleep-time compute (Letta + UC Berkeley, Ch4): consolidation runs during idle periods, not while a user waits. Shifting it off the response path cuts active inference cost ~5x and lets you pre-compute inferences (which tasks are at risk, given a deadline + dependencies) before anyone asks.

When to Use

  • An agent with accumulating episodic memory that grows noisy over time
  • DevOps incident memory: turn many similar 503-after-deploy incidents into one durable Pattern node with a runbook
  • Conversational assistants that repeat the same fact across sessions
  • Any system that needs to answer "how do you know X?" with a provenance trace

Phrases: "consolidate memory", "summarize episodes", "sleep-time compute", "provenance chain", "compress experience into knowledge", "cluster incidents".

When NOT to Use

  • One-shot / stateless agents — there is nothing to consolidate
  • The synchronous response path — consolidation is a background/idle job
  • Facts that must remain individually addressable (an audit log of distinct events) — consolidation deliberately merges them
  • Clusters that never reach the minimum size — keep the raw episodes; do not fabricate a pattern from one example

Process

StepInputActionOutputVerification
1list of raw episodeslib.cluster_by_topic(episodes, threshold)list of clustersrelated episodes group; unrelated ones split
2one clusterlib.summarize_cluster(cluster)one durable fact stringmulti-episode summary carries a confirmation count
3all episodeslib.consolidate(episodes, min_cluster_size)list of ConsolidatedFactclusters below min size are skipped
4a fact + episodeslib.provenance_of(fact, episodes)source episodesround-trips; dangling links raise
5facts + idle workerlib.precompute_inferences(facts, inference_fn){fact_id: inferences}runs off the response path

CLI: cluster, consolidate, scenario incident-consolidation, benchmark.

Rationalizations

Agent rationalizationDocumented rebuttal
"I'll consolidate on every turn so memory is always fresh."Consolidation is expensive (clustering + summarization). The chapter's sleep-time-compute result is explicit: run it during idle periods, not the response path — ~5x cheaper active inference. On-turn consolidation pays the cost when the user is waiting.
"One vivid episode is enough to make a pattern."Example 4-13 sets if len(cluster) < 3: continue. A pattern from one example is an overfit. The minimum-size gate is part of the design, not a tuning knob.
"I'll drop the provenance links to save space."Then "how do you know the deadline is Friday?" becomes unanswerable and you cannot debug a wrong conclusion. The DERIVED_FROM chain is what makes consolidated knowledge trustworthy and inspectable.
"Sentence-level facts are simpler to extract."Sentence-level extraction fragments cross-turn context (Ch4). HINDSIGHT extracts 2-5 narrative facts per conversation. The summarizer_fn seam is where you swap the extractive default for the narrative LLM form.

Red Flags

  • Every episode lands in its own singleton cluster. The similarity threshold is too high, or the similarity function is mis-tuned for the domain (the default token-overlap may need an embedding swap).
  • One giant cluster swallows everything. Threshold too low — unrelated episodes are being glued together. Tighten it or switch to semantic similarity.
  • Consolidated facts have empty derived_from. The provenance chain was dropped — the fact is now unexplainable and undebuggable.
  • Consolidation appears in the request latency profile. It is running on the response path. Move it to a background/idle worker.

Non-Negotiable Verification

  1. Run the benchmark battery. python cli.py benchmark must report 10/10: related episodes cluster, the min-size gate skips small clusters, full provenance is recorded and round-trips, dangling provenance raises, clustering is deterministic, and sleep-time precompute keys by fact id.
  2. Verify CLI help. python cli.py --help exits 0 and prints the SKILL.md description.

Security Posture

  • Prompt injection. Episodes are untrusted content, and repetition is the attack: planting the same false claim >= min-cluster-size times manufactures a "confirmed 3 times" consolidated fact. Clustering never executes episode text; the provenance chain is the audit path - inspect sources before trusting a consolidated node.
  • Data exfiltration. Consolidation copies episode content into durable nodes: sensitive details survive in summaries and DERIVED_FROM links long after raw episodes age out. Redact before consolidating; the skill makes no network calls and writes no files itself.
  • Privilege escalation. No shell invocation, no eval. Consolidated facts gain durable, trusted standing in the graph, and sleep-time jobs run unattended - bound the background job's write scope and gate what gets promoted from episode to knowledge.

Source Attribution

Distilled from Agentic GraphRAG (O'Reilly) by Anthony Alcaraz and Sam Julien — Ch4: Memory — "Consolidation: From Experience to Knowledge" (Example 4-5) and "Adding Memory to the DevOps Agent" (Example 4-13). Sleep-time compute: Letta + UC Berkeley research cited in Ch4. Narrative-fact extraction: HINDSIGHT (Latimer et al. 2025).

Mitgelieferte Dateien

Das Modell liest diese Dateien bei Bedarf, während der Skill geladen ist. Sie werden als lesbare Dateien bereitgestellt und niemals ausgeführt.

Häufig gestellte Fragen

Was macht der KI-Skill Memory Consolidation?

Consolidation pipeline — turn noisy raw episodes into durable knowledge (Agentic GraphRAG Ch4, Example 4-5 + Example 4-13). Four steps: cluster related episodes by topic, summarize each cluster into one consolidated fact, create the consolidated node, and maintain a provenance chain back to the source episodes so "how do you know that?" is answerable. Clusters below a minimum size (default 3) are skipped — not enough examples to generalize. Adds the sleep-time-compute discipline: run consolidation during idle periods, never on the synchronous response path, and pre-compute inferences that a...

Warum Memory Consolidation in TypingMind nutzen?

Weil Sie den Skill einmal installieren und mit jedem Modell verwenden können. Memory Consolidation besteht aus reinem Markdown statt aus anbieterspezifischem Code. So funktioniert derselbe Skill mit GPT-5, Claude, Gemini, Grok oder einem lokalen Modell – und Sie können das Modell mitten im Chat wechseln, ohne dass der Skill seine Funktion verliert. TypingMind verwendet Ihre eigenen API-Schlüssel. Sie bezahlen die Anbieter daher direkt statt über ein Abonnement pro Nutzerplatz, und Ihre Skills und Chats bleiben in Ihrem eigenen Speicher.

Wie installiere ich Memory Consolidation in TypingMind?

Öffnen Sie in TypingMind Plugins → Skills → Von GitHub installieren und fügen Sie https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/memory/memory-consolidation ein. TypingMind liest die Datei SKILL.md, bündelt die zugehörigen Dateien und installiert alles als Skill, den Sie für jeden Chat einzeln aktivieren können.

Welche KI-Modelle können Memory Consolidation nutzen?

Jedes Modell, das Sie mit TypingMind verbinden. KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher können GPT, Claude, Gemini, Grok und lokale Modelle diesen Skill laden, wenn eine Anfrage dazu passt.

Wie viele KI-Modelle kann ich mit Memory Consolidation verwenden?

So viele Sie möchten. In TypingMind können Sie Memory Consolidation mit jedem Modell verwenden, das Skills unterstützt, etwa mit GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama. Dabei nutzen Sie Ihre eigenen API-Schlüssel.

Ist der KI-Skill Memory Consolidation kostenlos?

Ja. Der Skill wird von AnthonyAlcaraz auf GitHub unter der Lizenz MIT veröffentlicht. Sie bezahlen nur Ihren eigenen KI-Anbieter für die verwendeten Token.

Was sind KI-Skills?

Ein KI-Skill ist ein wiederverwendbares Anweisungspaket, das einem KI-Modell vermittelt, wie es eine bestimmte Aufgabe erledigt. Es folgt dem offenen Format Agent Skills: Die Datei SKILL.md enthält den Namen und die Beschreibung des Skills. Hinzu kommen bei Bedarf Skripte, Vorlagen oder Referenzdateien für das Modell. Das Modell liest die Anweisungen nur, wenn Ihre Anfrage zum Skill passt. Ein installierter Skill verursacht daher erst Kosten, wenn er verwendet wird.

Wie unterscheiden sich KI-Skills von Plugins oder MCP-Servern?

Ein Plugin oder MCP-Server stellt einem Modell neue aufrufbare Tools bereit – Code, der auf einem System ausgeführt wird und ein Ergebnis zurückgibt. Ein KI-Skill vermittelt dem Modell stattdessen Wissen und Vorgehensweisen: wie es eine Aufgabe angeht, welche Schritte es befolgt und wie eine gute Ausgabe aussieht. Skills bestehen aus reinem Markdown und kommen daher ohne Server, API-Schlüssel und Laufzeitumgebung aus. Sie funktionieren mit jedem Modell.

Alle anzeigen

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇