Skip to content

decisions.md grows unbounded — agents waste context reading stale decisions #20

@diberry

Description

@diberry

Problem

decisions.md grows unbounded in active Squad projects. A real-world Squad deployment (MMO project) reached 145KB / 2,219 lines / ~35K tokens — and every agent reads the entire file at spawn time.

Impact

  • Context waste: Every agent burns ~35K tokens reading decisions before doing any work
  • Slower spawns: More data to parse = slower agent startup
  • Higher cost: Wasted tokens = wasted money on every agent interaction
  • Reduced capacity: Less room in the context window for actual task work
  • Compounding problem: Active projects generate 5-15 decisions/session; grows ~1-2KB/session

Root Cause Analysis

The current architecture has a write/read asymmetry:

  • Writes are incremental: Agents write small decisions to decisions/inbox/, Scribe merges them — this works great
  • Reads are monolithic: Every agent reads the ENTIRE decisions.md at spawn — this doesn't scale
  • Archival is reactive: The 20KB/30-day rule in Scribe Task StorageProvider: Phase 3 — CLI migration to SquadState APIs #5 exists but doesn't trigger reliably because:
    1. Scribe runs haiku (fast/cheap model) which sometimes skips the archival step
    2. The threshold check is a soft guideline, not enforced by code
    3. No automated mechanism exists outside of Scribe spawns

Evidence from User Report

"decisions.md is 149KB (~2,200 lines). Every agent reads it at spawn — that's ~35K tokens of context burned before any work starts."

The archive file was only 26KB despite the main file being 145KB — archival wasn't keeping pace with growth.

Current Mechanisms (and why they're insufficient)

Mechanism Location Issue
Scribe Task #5: Archive >20KB, >30 days squad.agent.md:869 Soft guideline, not enforced by code; Scribe (haiku) often skips it
Scribe deduplication scribe-charter.md:37-47 Handles exact dupes, but most decisions are unique
Nap skill .squad/skills/nap/ On-demand only; user must know to invoke it
History 12KB rule squad.agent.md:871 Only covers agent history.md, NOT decisions.md

Proposed Solutions

A. Changes to Squad Core (code/governance changes)

A1. Hard size enforcement in Scribe spawn prompt

Add explicit, measurable enforcement to the Scribe spawn template:

5. DECISIONS ARCHIVE (MANDATORY):
   a. Measure decisions.md size (wc -c or equivalent)
   b. If >20KB OR >100 entries:
      - Move entries older than 14 days to decisions-archive.md
      - Move entries with "Status: Implemented" regardless of age
      - Keep only entries from the last 14 days that are NOT implemented
   c. After archival, verify size is <20KB. If still over, archive entries >7 days old.
   d. Log: "📦 Archived {N} decisions ({old_size} → {new_size})"

A2. Decision index / summary section

Add a compact index at the top of decisions.md that agents can scan quickly:

## Decision Index (auto-generated by Scribe)
| ID | Date | Topic | Status | By |
|----|------|-------|--------|----|
| D-42 | 2026-03-20 | Use JWT for auth | Active | Ripley |
| D-41 | 2026-03-18 | Postgres over MySQL | Implemented | Dallas |
...

## Active Decisions (details below)
### 2026-03-20: Use JWT for auth
...

Agents reading decisions.md can scan the index (~2KB) and only deep-read entries relevant to their task.

A3. Scoped decision reads in spawn prompts

Instead of "Read .squad/decisions.md", change the spawn template to:

Read .squad/decisions.md — focus on the Decision Index at the top.
Only deep-read entries relevant to your current task domain: {task_domain}

This gives agents permission to skim rather than consuming every entry.

A4. decisions.md size check in squad nap

The nap skill already checks history.md (15KB) and total .squad/ (1MB). Add:

  • decisions.md >20KB → trigger archival
  • Make this part of the automated nap cycle, not just on-demand

A5. Configurable thresholds in .squad/config.json

Allow users to tune archival behavior:

{
  "decisions": {
    "maxSizeKB": 20,
    "archiveAfterDays": 14,
    "autoArchiveImplemented": true,
    "maxEntries": 100
  }
}

B. User-implementable solutions (ceremonies, skills, practices)

B1. "Decisions Cleanup" Ceremony

Users can add to .squad/ceremonies.md:

- name: Decisions Cleanup
  type: maintenance
  when: manual
  trigger: "decisions cleanup" or "clean decisions"
  facilitator: Scribe
  description: >
    Archive implemented and stale decisions. Rebuild decision index.
    Run when decisions.md exceeds 20KB or has >100 entries.
  steps:
    1. Scribe measures current size
    2. Scribe identifies implemented/stale entries (>30 days, status: implemented)
    3. Scribe moves them to decisions-archive.md
    4. Scribe rebuilds the Decision Index section
    5. Scribe reports: size before/after, entries archived

B2. "Decisions Hygiene" Skill

Users can create .squad/skills/decisions-hygiene/SKILL.md:

name: decisions-hygiene
description: Keep decisions.md under control
domain: squad-maintenance
confidence: medium
source: observed

Patterns:

  • Mark decisions as Status: Implemented when work is done
  • Use concise decision format (3-4 lines max per entry)
  • Prefix decisions with domain tags: [auth], [api], [ui] for filtering
  • Run decisions cleanup ceremony weekly in active projects

B3. Session-start size check

Users can add to their Lead's charter or a personal agent:

At session start, check the size of .squad/decisions.md.
If >20KB, recommend: "⚠️ decisions.md is {size}KB — consider running 'decisions cleanup'"

B4. Ralph integration

Add a decisions size check to Ralph's idle-watch:

When board is clear AND decisions.md > 20KB:
  "📦 decisions.md is {size}KB — spawning Scribe for archival"
  → Auto-spawn Scribe with archival task

Success Criteria

  • Active decisions.md stays under 20KB (~5K tokens) in steady state
  • Archival runs automatically, not just when users remember to invoke it
  • Agents can efficiently read only relevant decisions
  • Users have ceremony/skill patterns for manual cleanup when needed
  • Config allows tuning thresholds per project

Labels

squad, enhancement, squad:lead

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgo:needs-researchNeeds investigationsquadSquad triage inbox — Lead will assign to a membersquad:fidoAssigned to FIDO (Quality Owner)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions