refactor(memory): run Dream and Skill evolution in agent sessions - #637
Open
xiami762 wants to merge 25 commits into
Open
refactor(memory): run Dream and Skill evolution in agent sessions#637xiami762 wants to merge 25 commits into
xiami762 wants to merge 25 commits into
Conversation
added 10 commits
July 29, 2026 12:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
memory_searchas the retrieval interface while using the standardread/write/edit/glob/greptools to maintain curated Memory.self-improveAgent and one integrated prompt that can improve Memory or at most one Flocks-managed Skill.Key Changes
Memory hierarchy and lifecycle
<data>/memoryas the canonical Memory root (normally~/.flocks/data/memory; this is not~/.flocks/memory):USER.md— user identity/context, communication preferences, working style, and technical level.MEMORY.md— global environment/tool knowledge, lessons and corrections, and external references.projects/<project_id>/MEMORY.md— project context, project-specific lessons and corrections, and references.daily/YYYY-MM-DD.md— lifecycle-owned append-only evidence.write/editoperations against them; only lifecycle code may append Daily entries./newSession-to-Markdown snapshot hook.USER.mdMEMORY.mdMEMORY.mdSearch and indexing
memory_searchglobal across selectable sources:memorysearches User, Global, all Project, and Daily Memory.sessionsearches persisted user/assistant Session text across projects.(scope, scope_id, path).MemoryManager; file hashes keep the check cheap when content is unchanged.Unified Dream / self-improvement
Remove the retired
self-enhanceAgent, separate/learncommand, Skill-learning trigger pipeline, proposal persistence, and dual evolution state.Add one hidden disposable
self-improveAgent running through the normalSessionLoopwithmemory_enabled=False.Trigger self-improvement only:
/dreamfor the current Global or Project targetDo not trigger Dream at startup.
Feed the Agent incremental user/assistant Session evidence, bounded tool traces, target-mapped Daily evidence, and a complete-entry-trimmed Skill catalog. Curated Memory is inspected from disk instead of duplicated into the prompt.
Give the Agent
read,glob,grep,bash, and Skill-loading support, with writes restricted to the exact curated Memory paths and user Skill root.Require an explicit create/edit/no-op decision. A run may create or evolve at most one complete Skill, and may edit only Skills marked:
Preserve built-in, project, source-controlled, and otherwise unmanaged Skills; validate and restore guarded files if the Agent violates the write contract.
Advance the checkpoint only after the Agent run, output validation, and required index synchronization succeed. Skip Memory index synchronization when no Memory file changed.
Show manual
/dreamprogress and return a structured result with the target, evidence reviewed, and changed Memory/Skill files. Scheduled runs remain silent.Tests and cleanup
Impact Scope
/dreamnow reports progress and its final changes. Memory files use the hierarchy above, and/learn,memory_get, andmemory_writeare no longer available.Business Logic to Review
/dreamstatus cleanup on both success and failure.Why This Approach
SessionLoopgives Dream the same prompt/tool/runtime contracts as other Agents while disabling recursive Memory injection.Test Plan
.venv/bin/ruff checkpasses for changed Python files exceptflocks/server/app.py, which retains pre-existing repository E402 findings..venv/bin/pytest tests/memory tests/command/test_evolution_commands.py tests/server/test_input_dispatcher.py tests/session/test_status.py tests/sandbox/test_sandbox_file_tools.py tests/tool/test_memory_file_write.py -q— 126 passed.cd webui && npm run lintcd webui && npm run test:run -- src/components/common/SessionChat.test.ts src/pages/Session/index.test.tsx src/features/session-chat/sseActions.test.ts— 218 passed.cd webui && npm run buildCompatibility, Migration & Rollback
memory_get,memory_write,/learn, the previous automatic Skill-learning triggers, and the legacy Session Memory hook. Integrations should usememory_search, standard file tools, and/dream.~/.flocks/data/memory; this PR does not move Memory to~/.flocks/memory.