Memory Dag Compactor logo

Memory Dag Compactor

Community
ArchieIndian
memory-dag-compactor

Builds hierarchical summary DAGs from MEMORY.md with depth-aware prompts — leaf summaries preserve detail, higher depths condense to durable arcs, preventing information loss during compaction.

Overview

PublisherArchieIndian
Repositoryopenclaw-superpowers
Skill namememory-dag-compactor
Stars
74
Forks
14
Bundled files
3
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by ArchieIndian on GitHub. Read the source before you install it.

Installation

Install the Memory Dag Compactor AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/ArchieIndian/openclaw-superpowers/tree/main/skills/openclaw-native/memory-dag-compactor
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ArchieIndian/openclaw-superpowers.git /tmp/openclaw-superpowers
mkdir -p .claude/skills
cp -r /tmp/openclaw-superpowers/skills/openclaw-native/memory-dag-compactor .claude/skills/memory-dag-compactor
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Memory Dag Compactor in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Memory Dag Compactor on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Memory Dag Compactor is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Memory DAG Compactor

What it does

Standard memory compaction is lossy — older entries get truncated and details disappear forever. Memory DAG Compactor replaces flat compaction with a directed acyclic graph (DAG) of hierarchical summaries inspired by lossless-claw's Lossless Context Management approach.

Each depth in the DAG uses a purpose-built prompt tuned for that abstraction level:

DepthNameWhat it preservesTimeline granularity
d0LeafFile operations, timestamps, specific actions, errorsHours
d1CondensedWhat changed vs. previous context, decisions madeSessions
d2ArcGoal → outcome → carries forwardDays
d3+DurableLong-term context that survives weeks of inactivityDate ranges

The raw MEMORY.md entries are never deleted — only organized into a searchable, multi-level summary hierarchy.

When to invoke

  • Automatically nightly at 11pm (cron) — compacts the day's memory entries
  • When MEMORY.md grows beyond a configurable threshold (default: 200 entries)
  • Before a long-running task — ensures memory is compact and searchable
  • When the agent reports "I don't remember" for something that should be in memory

How to use

bash
python3 compact.py --compact                      # Run leaf + condensation passes
python3 compact.py --compact --depth 0            # Only leaf summaries (d0)
python3 compact.py --compact --depth 2            # Condense up to d2 arcs
python3 compact.py --status                       # Show DAG stats and health
python3 compact.py --tree                         # Print the summary DAG as a tree
python3 compact.py --search "deployment issue"    # Search across all depths
python3 compact.py --inspect <summary-id>         # Show a summary with its children
python3 compact.py --dissolve <summary-id>        # Reverse a condensation
python3 compact.py --format json                  # Machine-readable output

Procedure

Step 1 — Run compaction

bash
python3 compact.py --compact

The compactor:

  1. Reads all entries from MEMORY.md
  2. Groups entries into chunks (default: 20 entries per leaf)
  3. Generates d0 leaf summaries preserving operational detail
  4. When leaf count exceeds fanout (default: 5), condenses into d1 summaries
  5. Repeats condensation at each depth until DAG is within budget
  6. Writes the summary DAG to state

Step 2 — Search memory across depths

bash
python3 compact.py --search "API migration"

Searches raw entries and all summary depths. Results ranked by relevance and depth — deeper summaries (d0) are more detailed, shallower (d3+) give the big picture.

Step 3 — Inspect and repair

bash
python3 compact.py --tree             # Visualize the full DAG
python3 compact.py --inspect s-003    # Show summary with lineage
python3 compact.py --dissolve s-007   # Reverse a bad condensation

Depth-aware prompt design

d0 (Leaf) — Operational detail

Preserves: timestamps, file paths, commands run, error messages, specific values. Drops: conversational filler, repeated attempts, verbose tool output.

d1 (Condensed) — Session context

Preserves: what changed vs. previous state, decisions made and why, blockers encountered. Drops: per-file details, exact timestamps, intermediate steps.

d2 (Arc) — Goal-to-outcome arcs

Preserves: goal definition, final outcome, what carries forward, open questions. Drops: session-level detail, individual decisions, specific tools used.

d3+ (Durable) — Long-term context

Preserves: project identity, architectural decisions, user preferences, recurring patterns. Drops: anything that wouldn't matter after 2 weeks of inactivity.

Configuration

ParameterDefaultDescription
chunk_size20Entries per leaf summary
fanout5Max children before condensation triggers
max_depth4Maximum DAG depth
token_budget8000Target token count for assembled context

State

DAG structure, summary content, and lineage stored in ~/.openclaw/skill-state/memory-dag-compactor/state.yaml.

Fields: last_compact_at, dag_nodes, dag_edges, entry_count, compact_history.

Notes

  • Never modifies or deletes MEMORY.md — the DAG is an overlay
  • Each summary includes a [Expand for details about: ...] footer listing what was compressed
  • Dissolve reverses a condensation, restoring child summaries to the active set
  • Inspired by lossless-claw's DAG-based summarization hierarchy and depth-aware prompt system

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Memory Dag Compactor AI skill do?

Builds hierarchical summary DAGs from MEMORY.md with depth-aware prompts — leaf summaries preserve detail, higher depths condense to durable arcs, preventing information loss during compaction.

Why use Memory Dag Compactor on TypingMind?

Because you install it once and use it with any model. Memory Dag Compactor is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Memory Dag Compactor in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ArchieIndian/openclaw-superpowers/tree/main/skills/openclaw-native/memory-dag-compactor. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Memory Dag Compactor?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Memory Dag Compactor?

As many as you like. As long as a model supports skills, you can use Memory Dag Compactor with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Memory Dag Compactor AI skill free?

It is published on GitHub by ArchieIndian. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇