Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ docker run -p 50001:80 agent0ai/agent-zero

- Agent Zero is not pre-programmed for specific tasks (but can be). It is meant to be a general-purpose personal assistant. Give it a task, and it will gather information, execute commands and code, cooperate with other agent instances, and do its best to accomplish it.
- It has a persistent memory, allowing it to memorize previous solutions, code, facts, instructions, etc., to solve tasks faster and more reliably in the future.
- Its AutoDream layer also maintains a Claude Code-style `MEMORY.md` index for each memory scope or project, backed by durable markdown memories and synchronized with the vector database so symbolic navigation and semantic recall stay aligned.

![Agent 0 Working](/docs/res/ui_screen2.png)

Expand Down
28 changes: 28 additions & 0 deletions plugins/_memory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@ This plugin stores memories and knowledge embeddings in a FAISS-backed vector da
- Exposes search, delete, bulk delete, update, and subdirectory listing endpoints for the memory dashboard.
- **Scoped storage**
- Supports different memory subdirectories so memory can be separated by context or agent scope.
- **AutoDream durable memory**
- Periodically performs a reflective background pass over recent sessions and recent memory fragments.
- Maintains a compact `MEMORY.md` index plus durable markdown memory files under each memory subdirectory.
- Feeds the dream with both fresh vector memories and semantically related older vector memories so consolidation has better historical context.
- Writes a lightweight `.dream-log.md` changelog for fast auditing of what each run created, updated, pruned, or flagged.
- Re-imports durable memory files into vector memory with frontmatter metadata preserved, so recall benefits from the consolidated output without embedding raw YAML headers.

## Claude Code `MEMORY.md` Integration

Agent Zero's AutoDream intentionally follows the same broad pattern as Claude Code's `MEMORY.md`, but it does so per memory scope instead of assuming one global file.

- **Scoped index, not a dump**
- Each memory scope gets its own `autodream/MEMORY.md`.
- That file is a compact index of durable memories, not the memories themselves.
- **Durable files hold the actual content**
- The detailed memories live in `autodream/memories/*.md`.
- `MEMORY.md` links to those files with one-line descriptions.
- **Vector DB stays in sync**
- Those durable markdown files are re-imported into the FAISS-backed vector store.
- This means Agent Zero's semantic recall and the Claude-style `MEMORY.md` index are two synchronized views over the same durable memory set.
- **Compatibility model**
- If you already use Claude Code, the generated `MEMORY.md` should feel familiar.
- The main difference is placement: Agent Zero manages `MEMORY.md` inside each memory scope or project metadata folder rather than at a single repository root.
- If another tool expects a root-level `MEMORY.md`, you can mirror or sync the generated index there, but Agent Zero's native source of truth remains the scoped AutoDream folder.

## Key Files

Expand All @@ -28,6 +52,8 @@ This plugin stores memories and knowledge embeddings in a FAISS-backed vector da
- `helpers/knowledge_import.py` imports external knowledge into memory storage.
- **Consolidation**
- `helpers/memory_consolidation.py` contains memory consolidation logic.
- **AutoDream**
- `helpers/auto_dream.py` contains session gathering, durable file generation, and background scheduling logic.
- **Tools**
- `tools/memory_save.py`
- `tools/memory_load.py`
Expand All @@ -37,6 +63,8 @@ This plugin stores memories and knowledge embeddings in a FAISS-backed vector da
- **API**
- `api/memory_dashboard.py` powers the memory management dashboard.
- `api/import_knowledge.py` and `api/knowledge_reindex.py` handle knowledge import and reindexing.
- **Lifecycle**
- `extensions/python/process_chain_end/_60_auto_dream.py` schedules periodic AutoDream runs after top-level chats complete.

## Configuration Scope

Expand Down
6 changes: 5 additions & 1 deletion plugins/_memory/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ memory_recall_post_filter: false
memory_memorize_enabled: true
memory_memorize_consolidation: true
memory_memorize_replace_threshold: 0.9
agent_memory_subdir: default
memory_auto_dream_enabled: false
memory_auto_dream_min_hours: 8
memory_auto_dream_min_sessions: 3
memory_auto_dream_line_limit: 120
agent_memory_subdir: default
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from agent import AgentContextType
from helpers import persist_chat, plugins
from helpers.extension import Extension

from plugins._memory.helpers.auto_dream import schedule_auto_dream
from plugins._memory.helpers.memory import get_agent_memory_subdir


class AutoDream(Extension):

async def execute(self, **kwargs):
if not self.agent:
return
if self.agent.number != 0:
return
if self.agent.context.type == AgentContextType.BACKGROUND:
return

config = plugins.get_plugin_config("_memory", self.agent) or {}
if not config.get("memory_memorize_enabled"):
return
if not config.get("memory_auto_dream_enabled"):
return

if self.agent.config.profile:
self.agent.context.set_data("agent_profile", self.agent.config.profile)

persist_chat.save_tmp_chat(self.agent.context)

schedule_auto_dream(
context_id=self.agent.context.id,
project_name=self.agent.context.get_data("project"),
agent_profile=self.agent.config.profile,
memory_subdir=get_agent_memory_subdir(self.agent),
)
Loading