Skip to content
Guides/Memory

Memory for Agent Loops

Short answer

Long-running loops need memory strategy: what to keep, what to summarize, what to retrieve, and what to forget.

Why it matters

Without a memory plan, a loop either forgets what it learned or drowns in context. Deciding up front what to persist and what to drop keeps loops both coherent and affordable.

Practical checklist

  • Keep durable facts (goal, constraints, decisions)
  • Summarize long histories instead of re-sending them
  • Retrieve only the observations relevant to the next step
  • Forget stale or one-off detail

Example

A multi-day refactor loop keeps a short “decisions so far” note, retrieves the files touched this session, and summarizes everything else — rather than re-reading the whole repo each run.

Common failure modes

No persistence, so the loop relearns each run
Unbounded context growth
Retrieving irrelevant memory that distracts the agent

Related templates

Sources & further reading