Skip to content

feat(dream): add unified self-improvement agent - #666

Open
xiami762 wants to merge 1 commit into
devfrom
feat/dream-self-improvement
Open

feat(dream): add unified self-improvement agent#666
xiami762 wants to merge 1 commit into
devfrom
feat/dream-self-improvement

Conversation

@xiami762

@xiami762 xiami762 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a unified Dream self-improvement Agent that reviews incremental experience and makes evidence-backed updates to durable Memory or managed user Skills.
  • Support both explicit /dream execution and scheduled background execution through the same implementation.

Key Changes

  • Add the hidden self-improve Agent with the standard Agent prompt-building flow and read, write, edit, search, Skill, and Bash capabilities.
  • Add a single Dream pipeline that consumes bounded Session text/tool traces and recent Daily evidence, then applies precise Memory or managed Skill changes.
  • Add /dream command handling with visible progress, disabled-state, completion, no-change, and failure output in direct chat and WebUI flows.
  • Add the scheduled Dream runner, lifecycle state/watermarks, catch-up behavior, and no-op handling when no durable change is justified.
  • Restrict Skill edits to user Skills marked with metadata.managed_by: flocks, with read-before-write and post-change validation.
  • Guard Daily Memory and non-target files across file tools, sandbox paths, and Dream execution.
  • Add memory.dream configuration with enablement, interval, and recent-Daily window settings.

Impact Scope

  • User-visible behavior: /dream runs self-improvement for the active Session and reports what changed; scheduled Dream can run in the background.
  • Compatibility / migration: Replaces the previous split Dream/Learn evolution path; no state migration is required for the new evolution state.
  • Configuration / environment: Adds memory.dream.enabled, interval_hours, and recent_daily_days; Dream is enabled by default with a 24-hour interval.
  • Dependencies: No new third-party dependencies.
  • Performance / resources: A scheduled run may invoke one bounded background Agent execution per eligible interval. Input and tool steps are capped.
  • Security / permissions: The Agent can use Bash and file tools, but writes are constrained to the exact Memory targets and curator-managed user Skills. Daily and installed/source Skills remain protected.

Business Logic to Review

  • Manual and scheduled trigger eligibility, watermark advancement, catch-up limits, and the distinction between failed, no-op, and successful runs.
  • Evidence construction and budgeting: Session user/assistant text, bounded tool traces, recent Daily files, and Skill catalog serialization.
  • Prompt routing between USER, Global Memory, Project Memory, and Skills, including canonical ownership and NO_CHANGES behavior.
  • Skill ownership checks, read-before-write enforcement, path/sandbox guards, and post-run change validation.
  • Foreground /dream status/output behavior versus silent scheduled execution.

Why This Approach

  • Uses one Agent and one comprehensive prompt for both Memory curation and Skill evolution, avoiding divergent Dream and Learn implementations.
  • Runs through the standard Agent flow with explicit write boundaries, keeping the implementation small while preserving normal tool and sandbox enforcement.

Test Plan

  • uv run pytest tests/command/test_evolution_commands.py tests/memory/test_evolution.py tests/memory/test_evolution_agent_runner.py tests/sandbox/test_sandbox_file_tools.py tests/server/test_input_dispatcher.py tests/server/test_lifespan.py tests/session/test_lifecycle_hooks.py tests/session/test_prompt_tokens.py tests/session/test_status.py tests/skill/test_skill.py -q (190 passed)
  • npm run test:run -- src/components/common/SessionChat.test.ts src/pages/Session/index.test.tsx (213 passed)
  • npm run lint
  • npm run build

Compatibility, Migration & Rollback

  • No migration is required for the new Dream evolution state.
  • Set memory.dream.enabled to false to stop manual and scheduled Dream execution without changing Memory files or Skills.
  • Reverting the PR removes the runner and command path; existing Markdown Memory and generated Skills remain ordinary files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant