> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agents-squads.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory

> Persistent context across sessions

## Why Memory Matters

Without memory, every session starts fresh. With memory, agents build on previous work.

Memory enables:

* **Continuity** — Pick up where you left off
* **Learning** — Accumulate knowledge over time
* **Coordination** — Share context between agents

## Memory Structure

```
.agents/memory/
├── company/
│   └── strategy.md        # Company identity, the "why" behind all work
├── research/
│   ├── goals.md            # Measurable targets for this squad
│   ├── active-work.md      # Open PRs/issues — prevents duplication
│   ├── feedback.md         # Last cycle's evaluation
│   └── analyst/
│       └── state.md        # What this agent already knows
└── daily-briefing.md        # Cross-squad context
```

## The Context Cascade

Memory isn't a flat key-value store — it's a **layered cascade** loaded before
every agent execution, in strict priority order. When the token budget runs
out, lower layers drop first, so an agent never loses its identity or mission,
only the less-critical context underneath it:

| # | Layer            | Source                            | Drops first? |
| - | ---------------- | --------------------------------- | :----------: |
| 0 | System Protocol  | `config/SYSTEM.md`                |     never    |
| 1 | Company Strategy | `memory/company/strategy.md`      |     last     |
| 2 | Goals            | `memory/{squad}/goals.md`         |              |
| 3 | Active Work      | `memory/{squad}/active-work.md`   |              |
| 4 | Agent State      | `memory/{squad}/{agent}/state.md` |              |
| 5 | Feedback         | `memory/{squad}/feedback.md`      |              |
| 6 | Briefings        | `memory/daily-briefing.md`        |     first    |

Not every role loads every layer — **scanners** get strategy, goals, and their
own state (they discover, don't decide); **workers** add feedback and active
work; **leads** and **evaluators** get all seven layers, since they need the
full picture to coordinate or judge output quality.

## Memory Types

### Agent State

Private to each agent (`{squad}/{agent}/state.md`):

* Task history
* Learned preferences
* Work in progress

### Squad Memory

Shared across agents in a squad (`goals.md`, `active-work.md`, `feedback.md`):

* Measurable targets
* What's already in flight
* The last cycle's evaluation — what was valuable, what was noise

## Managing Memory

```bash theme={null}
# Search all memory
squads memory query "competitor analysis"

# Read squad memory
squads memory read research

# List all memory entries
squads memory list

# Persist a learning
squads memory write research "Competitor X raised a Series B"
```

## Memory in Practice

When an agent runs:

1. **Load** — Retrieve relevant memory
2. **Inject** — Add to agent context
3. **Execute** — Agent works with full context
4. **Update** — Store new learnings

```markdown theme={null}
<!-- .agents/memory/research/analyst/state.md -->

# Research Analyst Memory

## Recent Work
- Completed competitive analysis on 2024-01-15
- Identified 3 new market entrants

## Key Findings
- Market growing 15% YoY
- Main competitor raised Series B

## Next Steps
- Deep dive on pricing strategies
- Interview customer segment
```
