Swarms agents persist their interaction history to disk through a per-agentDocumentation Index
Fetch the complete documentation index at: https://docs.swarms.world/llms.txt
Use this file to discover all available pages before exploring further.
MEMORY.md file. Set persistent_memory=True (the default) and reuse the same agent_name across process starts to resume the same memory.
When to use it
- The agent runs in separate processes (CLI, cron, restarts) and needs to resume prior context.
- You want a human-readable transcript of what the agent has seen and produced.
- You need to inspect, search, or export the agent’s interaction log.
long_term_memory (RAG) instead — MEMORY.md is for the agent’s own history, not a document index.
How it works
Memory is keyed byagent_name and lives under the workspace directory:
MEMORY.md and injects it into conversation_history as a single System message. Every conversation.add(...) then write-throughs to disk so nothing is lost on exit.
Basic example
Setagent_name and persistent_memory=True (the default). On the first run Swarms creates MEMORY.md. On subsequent runs the prior conversation is preloaded as a system preamble and the agent picks up where it left off:
Resume across restarts
Re-instantiate an agent with the sameagent_name and persistent_memory=True. The prior transcript is preloaded as a system message before the new task runs:
id changes between runs and is not used as the key.
Inspect memory in code
TheConversation object is exposed as agent.short_memory:
Export and reload
Snapshot memory to JSON or YAML and reload it later:Disable disk-backed memory
For privacy-sensitive or one-off agents, setpersistent_memory=False. In-process conversation_history still works for the duration of the run, but nothing is written to disk and nothing is preloaded next time:
Tips
- Use stable, descriptive
agent_namevalues for any agent that should remember prior work. - Don’t reuse the same
agent_nameacross unrelated tasks — memory will leak between runs. - For long-running agents, also enable context compression so memory stays within the model’s context window.
See also
- Agent Memory Reference — Full memory stack, lifecycle, and disk layout.
- Context Compression — Keep persistent memory within the context window.
- Conversation API — Underlying class for export, load, and search.