Repository navigation
feat(memory): tiered agent memory skill — hot/cold/wiki tiers #606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a656b0
56c8883
50843f2
0d8cf6a
48902da
5d4d2e3
656f7b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@bradygaster/squad-cli": minor | ||
| "@bradygaster/squad-sdk": minor | ||
| --- | ||
| feat: add tiered-memory skill for hot/cold/wiki agent context management |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # Proposal: Tiered Agent Memory Skill | ||
|
|
||
| **Issue:** bradygaster/squad#600 | ||
| **Author:** tamirdresher | ||
| **Date:** 2026-03-26 | ||
| **Status:** Proposal | ||
|
|
||
| --- | ||
|
|
||
| ## Problem Statement | ||
|
|
||
| Squad agents load their full conversation history on every spawn. In production, top agents carry: | ||
|
|
||
| | Agent | Context Size | Old Noise % | | ||
| |-------|-------------|-------------| | ||
| | Picard | 74KB / 18,500 tokens | 96% | | ||
| | Scribe | 52KB / 13,000 tokens | 91% | | ||
| | Data | 43KB / 10,700 tokens | 88% | | ||
| | Ralph | 38KB / 9,500 tokens | 85% | | ||
| | Worf | 34KB / 8,500 tokens | 82% | | ||
|
|
||
| 82-96% of each agent's context is "old noise" — past decisions, completed tasks, and ended | ||
| conversations. This wastes tokens, increases spawn latency, and risks agents hallucinating | ||
| stale context as current fact. | ||
|
|
||
| --- | ||
|
|
||
| ## Proposed Approach | ||
|
|
||
| Replace monolithic context loading with a three-tier model: | ||
|
|
||
| **Hot Tier (~2-4KB, always loaded):** Current session context only. Task description, active | ||
| decisions this session, last 3-5 actions, current blockers. | ||
|
|
||
| **Cold Tier (~8-12KB, on-demand):** Summarized cross-session history compressed by Scribe | ||
| (~10:1 compression). Load with --include-cold when task needs history. | ||
|
|
||
| **Wiki Tier (variable, selective read):** Durable structured knowledge — ADRs, stable | ||
| conventions, API contracts, agent charters. Load with --include-wiki. | ||
|
|
||
| **Result:** 20-55% context reduction per spawn with better relevance. | ||
|
|
||
| ### Scribe Integration | ||
|
|
||
| Scribe automates tier promotion: | ||
| - End of session: Scribe compresses Hot → Cold summary | ||
| - After 30 days: Scribe promotes Cold → Wiki for aged stable decisions | ||
| - On-demand: Any agent can request a wiki entry with scribe:wiki-write | ||
|
|
||
| --- | ||
|
|
||
| ## Fit with Existing Architecture | ||
|
|
||
| - **Complements** Scribe's existing session summary role (formalizes it with structured output) | ||
| - **No changes to existing agents** — coordinators opt in by including cold/wiki sections | ||
| - **File layout** uses existing .squad/ directory convention | ||
| - **No code changes** — template-only skill, spawn templates are guidelines | ||
|
|
||
| --- | ||
|
|
||
| ## What Changes | ||
|
|
||
| - New skill: packages/squad-cli/templates/skills/tiered-memory/SKILL.md | ||
| - New skill: packages/squad-sdk/templates/skills/tiered-memory/SKILL.md | ||
| - New changeset: .changeset/tiered-memory.md | ||
|
|
||
| ## What Stays the Same | ||
|
|
||
| - Existing spawn templates unchanged (opt-in) | ||
| - Scribe charter not modified (skill provides guidance, Scribe charter update is separate) | ||
| - No CLI or SDK runtime code changed | ||
|
Comment on lines
+61
to
+71
|
||
|
|
||
| --- | ||
|
|
||
| ## Risks and Mitigations | ||
|
|
||
| | Risk | Likelihood | Impact | Mitigation | | ||
| |------|-----------|--------|------------| | ||
| | Cold tier grows stale without Scribe automation | Medium | Low | Skill documents TTL; manual promotion works too | | ||
| | Wiki tier becomes a dumping ground | Low | Medium | Skill explicitly scopes Wiki to stable facts only | | ||
| | Cold compression loses important context | Low | Medium | Scribe keeps 10% verbosity; agents can load raw cold if needed | | ||
|
|
||
| --- | ||
|
|
||
| ## References | ||
|
|
||
| - Issue: bradygaster/squad#600 | ||
| - Production measurements: tamirdresher/tamresearch1 (June 2025) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,234 @@ | ||||||||||||||
| --- | ||||||||||||||
| name: tiered-memory | ||||||||||||||
| description: Three-tier agent memory model (hot/cold/wiki) for 20-55% context reduction per spawn | ||||||||||||||
| domain: memory-management, performance | ||||||||||||||
| confidence: high | ||||||||||||||
| source: earned (production measurements in tamirdresher/tamresearch1, 34-74KB baseline payloads) | ||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| # Skill: Tiered Agent Memory | ||||||||||||||
|
|
||||||||||||||
| ## Overview | ||||||||||||||
|
|
||||||||||||||
| Squad agents currently load their full context history on every spawn, resulting in 34–74KB payloads per agent (8,800–18,500 tokens). Measurement shows 82–96% of that context is "old noise" — information that is no longer relevant to the current task. The Tiered Agent Memory skill introduces a three-tier memory model that eliminates this bloat, achieving 20–55% context reduction per spawn in production. | ||||||||||||||
|
|
||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| ## Memory Tiers | ||||||||||||||
|
|
||||||||||||||
| ### 🔥 Hot Tier — Current Session Context | ||||||||||||||
| - **Size target:** ~2–4KB | ||||||||||||||
| - **Load policy:** Always loaded. Every spawn includes hot memory by default. | ||||||||||||||
| - **Contents:** Current task description, active decisions made this session, immediate blockers, last 3–5 actions taken, who you are talking to right now. | ||||||||||||||
| - **Lifetime:** Current session only. Discarded after session ends (Scribe promotes relevant parts to Cold). | ||||||||||||||
| - **Purpose:** Provide immediate task context without any latency or load decision. | ||||||||||||||
|
|
||||||||||||||
| ### ❄️ Cold Tier — Summarized Cross-Session History | ||||||||||||||
| - **Size target:** ~8–12KB | ||||||||||||||
| - **Load policy:** Load on demand. Include only when the task explicitly needs history. | ||||||||||||||
| - **Contents:** Summarized past sessions (compressed by Scribe), cross-session decisions, recurring patterns, unresolved issues from prior work. | ||||||||||||||
| - **Lifetime:** 30 days rolling window. After 30 days, Scribe promotes to Wiki tier. | ||||||||||||||
| - **Purpose:** Answer "what have we tried before?" and "what was decided?" without replaying full transcripts. | ||||||||||||||
| - **How to include:** Pass `--include-cold` in spawn template or add `## Cold Memory` section. | ||||||||||||||
|
|
||||||||||||||
| ### 📚 Wiki Tier — Durable Structured Knowledge | ||||||||||||||
| - **Size target:** variable, structured reference docs | ||||||||||||||
| - **Load policy:** Async write, selective read. Load only when task requires domain knowledge. | ||||||||||||||
| - **Contents:** Architecture decisions (ADRs), agent charters, routing rules, stable conventions, external API contracts, known platform constraints. | ||||||||||||||
| - **Lifetime:** Permanent until explicitly deprecated. | ||||||||||||||
| - **Purpose:** Authoritative reference. Not history — structured facts. | ||||||||||||||
| - **How to include:** Pass `--include-wiki` or reference specific wiki doc paths in spawn template. | ||||||||||||||
|
|
||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| ## When to Load Each Tier | ||||||||||||||
|
|
||||||||||||||
| | Situation | Hot | Cold | Wiki | | ||||||||||||||
| |-----------|-----|------|------| | ||||||||||||||
| | New task, no prior context needed | ✅ | ❌ | ❌ | | ||||||||||||||
| | Resuming interrupted work | ✅ | ✅ | ❌ | | ||||||||||||||
| | Debugging a recurring issue | ✅ | ✅ | ❌ | | ||||||||||||||
| | Implementing against a spec/ADR | ✅ | ❌ | ✅ | | ||||||||||||||
| | Onboarding to unfamiliar subsystem | ✅ | ❌ | ✅ | | ||||||||||||||
| | Post-incident review | ✅ | ✅ | ✅ | | ||||||||||||||
|
|
||||||||||||||
|
Comment on lines
+46
to
+54
|
||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| ## Spawn Template Pattern | ||||||||||||||
|
|
||||||||||||||
| The default spawn prompt should include **Hot tier only**: | ||||||||||||||
|
|
||||||||||||||
| ``` | ||||||||||||||
| ## Memory Context | ||||||||||||||
|
|
||||||||||||||
| ### Hot (current session) | ||||||||||||||
| {hot_context} | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| Add `--include-cold` when the task needs history: | ||||||||||||||
| ``` | ||||||||||||||
| ## Memory Context | ||||||||||||||
|
|
||||||||||||||
| ### Hot (current session) | ||||||||||||||
| {hot_context} | ||||||||||||||
|
|
||||||||||||||
| ### Cold (summarized history — load on demand) | ||||||||||||||
| See: .squad/memory/cold/{agent-name}.md | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| Add `--include-wiki` when the task needs domain knowledge: | ||||||||||||||
| ``` | ||||||||||||||
| ## Memory Context | ||||||||||||||
|
|
||||||||||||||
| ### Hot (current session) | ||||||||||||||
| {hot_context} | ||||||||||||||
|
|
||||||||||||||
| ### Wiki (durable reference) | ||||||||||||||
| See: .squad/memory/wiki/{topic}.md | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| ## Measurement Data | ||||||||||||||
|
|
||||||||||||||
| Baseline measurements from tamirdresher/tamresearch1 production runs (June 2025): | ||||||||||||||
|
|
||||||||||||||
| | Agent | Total Context | Old Noise % | Hot-Only Size | Savings | | ||||||||||||||
| |-------|--------------|-------------|---------------|---------| | ||||||||||||||
| | Picard (Lead) | 74KB / 18.5K tokens | 96% | ~3KB | 55% | | ||||||||||||||
| | Scribe | 52KB / 13K tokens | 91% | ~4KB | 48% | | ||||||||||||||
| | Data | 43KB / 10.7K tokens | 88% | ~3.5KB | 42% | | ||||||||||||||
| | Ralph | 38KB / 9.5K tokens | 85% | ~3KB | 38% | | ||||||||||||||
| | Worf | 34KB / 8.5K tokens | 82% | ~3KB | 20% | | ||||||||||||||
|
|
||||||||||||||
|
Comment on lines
+96
to
+103
|
||||||||||||||
| **Average savings: 20–55% per spawn** with Hot-only loading. Cold + Wiki on-demand adds ~2–8KB when needed, still well below current baselines. | ||||||||||||||
|
|
||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| ## Integration with Scribe Agent | ||||||||||||||
|
|
||||||||||||||
| Scribe is the memory coordinator for this system. It automates tier promotion: | ||||||||||||||
|
|
||||||||||||||
| 1. **End of session:** Scribe compresses Hot → Cold summary (keeps ~10% of session verbosity) | ||||||||||||||
| 2. **After 30 days:** Scribe promotes Cold → Wiki for decisions/facts that aged into stable knowledge | ||||||||||||||
| 3. **On-demand wiki writes:** Any agent can request Scribe to write a wiki entry mid-session using `scribe:wiki-write` | ||||||||||||||
|
|
||||||||||||||
| See Scribe charter: `.squad/agents/scribe/charter.md` | ||||||||||||||
|
Comment on lines
+114
to
+116
|
||||||||||||||
| 3. **On-demand wiki writes:** Any agent can request Scribe to write a wiki entry mid-session using `scribe:wiki-write` | |
| See Scribe charter: `.squad/agents/scribe/charter.md` | |
| 3. **On-demand wiki writes (recommended convention):** Teams may define a `scribe:wiki-write` command that agents can use to request mid-session wiki entries. | |
| If you adopt this, document the `scribe:wiki-write` workflow in your Scribe charter (e.g. `.squad/agents/scribe/charter.md`); it is not defined there by default. |
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The skill introduces runtime artifacts under .squad/memory/..., but .gitignore currently does not ignore .squad/memory/ (it only ignores .squad/log/, .squad/sessions/, etc.). This will likely create persistent untracked changes for users. Consider moving hot/cold tiers under an already-ignored runtime directory (e.g., .squad/sessions/) or update the repo ignore rules and clarify which tiers are intended to be committed.
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These references appear to be broken in this repo: there is no docs/tiered-memory-guide.md, and there is no skills/ directory at repo root (skills live under .copilot/skills/ and .squad/skills/, and this template is under packages/.../templates/skills/). Update the links/paths (or add the referenced guide file) so readers can navigate to the intended documentation.
| - See `skills/tiered-memory/SKILL.md` for full tier reference | |
| - See `docs/tiered-memory-guide.md` for wiring instructions | |
| - See `.squad/skills/tiered-memory/SKILL.md` (or `.copilot/skills/tiered-memory/SKILL.md`) for full tier reference | |
| - See the Tiered Memory wiring guide in your project's documentation for wiring instructions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This table uses
||at the start of each row, which renders as an unintended blank first column. Use a single leading|per row for proper markdown table formatting.