# Per-Agent Memory Files

This directory holds **per-agent personal memory files** — one markdown file per
named agent (e.g. `dallas.md`, `rebecca.md`). Each file is a personal notebook
for that agent: the consolidation pipeline appends inbox findings authored by
the agent to their own file, and the engine injects the agent's file into their
prompt context on every dispatch (alongside the broadcast `notes.md`).

## How it works

1. **Authoring**: When an agent writes a learnings file under
   `notes/inbox/<agent>-<task>-<date>.md`, the YAML frontmatter `agent:` field
   identifies the author. Filename prefix (`<agent>-...`) is used as fallback.
2. **Consolidation**: `engine/consolidation.js` runs on every tick. After the
   shared `notes.md` digest is written, `classifyToKnowledgeBase` also
   appends each item to `knowledge/agents/<agent>.md` when the agent is a
   known team member (matches `config.agents`). This is **strict superset**
   semantics — broadcast consolidation still happens; per-agent routing is in
   addition.
3. **Prompt injection**: `engine/playbook.js` injects, in order, `pinned.md`,
   `notes.md`, then `knowledge/agents/<agentId>.md` (when present) into the
   agent's prompt. Missing files are silently skipped.

## Conventions

- One `.md` file per agent, named `<agent-id>.md` (lowercase).
- Append-only from the consolidation engine — agents should not edit their
  own memory files directly. To record a learning, write to
  `notes/inbox/` as usual; the sweep will route it.
- Capped at ~25 KB per file; oldest sections are pruned at section
  boundaries to stay under budget.
- Frontmatter `agent:` in inbox notes is the canonical author field.
- Temp agents (e.g. `temp-mp1fnkze...`) are skipped — only configured
  team members get a memory file.
