AI Agent Memory Systems: How We Keep 13 Agents in Sync Across Sessions
SFD Lab's three-tier AI memory architecture: working memory, daily notes, long-term MEMORY.md. How 13 agents stay in sync across sessions, with real token optimization results.

Why Do AI Agents "Forget"?
Ever had this happen: you spend an hour with an AI planning out a complex workflow, come back the next day, and it has no idea what you're talking about? That's not a bug โ it's by design. LLMs have a finite context window, and when the session ends, it's gone.
For SFD Lab, where 13 agents collaborate across dozens of daily tasks โ spanning multiple sessions, channels, and days โ this is a serious operational problem. If every agent starts from zero every time, you lose half your efficiency.
Our Memory Architecture: Three Layers
After nearly 20 days of real-world use, we've converged on a three-tier memory model:
Layer 1: Working Memory (Session Context)
The LLM's context window. Fast, precise, but ephemeral. Use it for in-session task execution โ instructions, results, immediate handoffs. Gone when the session closes.
Layer 2: Daily Memory (Daily Notes)
Every agent writes a memory/YYYY-MM-DD.md file after completing tasks. What they did, what broke, what was triggered downstream. Start the next session by reading yesterday's file โ 5 minutes to restore full context.
# memory/2026-03-24.md
## Octopus Agent - Analytics Fix
- Fixed Fastify route registration path issue
- Changed: routes/analytics.js
- Gotcha: relative vs absolute paths; prefix controlled by parent registration
- Downstream: notified Bee to deploy, notified Hedgehog to verify
Layer 3: Long-Term Memory (MEMORY.md)
The distilled brain. Not a daily log โ rather, insights worth keeping: architecture decisions, hard-won lessons, team norms. Reviewed weekly, pruned regularly.
The Core Challenge: Cross-Session Sync
We've had countless "project team doesn't know anything" situations. Boss tells the main session a credential, next day a project session asks about it, nobody wrote it down, it's gone.
The fix: event-driven file writes. The rule: when the boss tells you anything โ credentials, decisions, rules โ write it to a file immediately. No file = lost information, no exceptions.
Token Budget and Memory Efficiency
Memory retrieval has a cost. Key optimizations:
- Layered loading: main session loads full MEMORY.md; sub-agents only load relevant fragments
- Summary-first: LEARNINGS.md contains distilled insights, not process logs
- Semantic search: use
memory_searchto retrieve by relevance, not by reading everything
In practice, this reduced average token consumption by ~40% while improving context hit rate significantly.
Preventing Memory Rot
Files go stale. Rules change. Old mandates get superseded but never deleted, and agents read contradictory instructions. Our solution: daily-reflection.py runs every night at 10 PM, audits memory files, flags contradictions, and notifies agents to update. Memory hygiene isn't optional โ it's part of the pipeline.
SFD Lab Note: Memory systems are really information governance. We're simulating human short-term/long-term memory with a filesystem. It's not perfect, but it works โ and it improves every day.