Skip to content

feat(sleep): add Sleep System for cognitive maintenance and memory co…#1

Open
bravostation wants to merge 310 commits intomainfrom
feature/sleep-system
Open

feat(sleep): add Sleep System for cognitive maintenance and memory co…#1
bravostation wants to merge 310 commits intomainfrom
feature/sleep-system

Conversation

@bravostation
Copy link
Owner

…nsolidation

Implements a scheduled, offline-first Sleep System that runs during user inactivity:

Shallow Sleep (Maintenance):

  • Config validation and integrity checks
  • Credential expiry detection
  • Integration connectivity probes
  • Update checks (OpenClaw, dependencies, tools)
  • Security scans (npm audit, credential patterns)
  • Development radar (new models, protocol updates)

Deep Sleep (Memory Consolidation):

  • Memory pruning (remove stale chunks)
  • Memory compaction (summarize sessions)
  • Medium-term memory processing
  • Long-term memory promotion
  • Core memory extraction (identity-shaping patterns)

Memory Hierarchy:

  • Short-term: Daily interactions (pruned during sleep)
  • Medium-term: Searchable context (promoted on reinforcement)
  • Long-term: Auto-loaded stable facts
  • Core: Identity-shaping behavioral patterns

Configuration via agents.defaults.sleep with customizable:

  • Sleep window (default: 03:00-06:00)
  • Idle requirements (default: 45 minutes)
  • Task toggles and thresholds

Includes:

  • Full documentation (docs/gateway/sleep.md)
  • Unit tests (51 tests passing)
  • Type-safe config with Zod validation

kimitaka and others added 30 commits February 1, 2026 09:16
* docs: document cacheRetention parameter (openclaw#6240)

* docs: standardize cacheRetention value quoting style

* style: format anthropic.md table

* Docs: align cacheRetention inline example

---------

Co-authored-by: Sebastian <sebslight@gmail.com>
* Docs: add zh-CN entrypoint translations

* Docs: harden docs-i18n parsing
…penclaw#5967)

* docs: fix anchor link for Google Vertex/Antigravity/Gemini section

* Docs: fix model provider MDX markers

---------

Co-authored-by: Sebastian <sebslight@gmail.com>
* fix: satisfy lint curly rule

* docs: apply oxfmt formatting
…claw#5663)

* docs(install): add pnpm approve-builds step for global installs

pnpm requires explicit approval for packages with build scripts.
Without running `pnpm approve-builds -g`, openclaw and its dependencies
(node-llama-cpp, sharp, protobufjs) won't have their postinstall scripts
executed, causing runtime errors.

Fixes openclaw#5579

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs(install): clarify pnpm reinstall step after approve-builds

Address review feedback: after running `pnpm approve-builds -g`,
users need to re-run the install command for postinstall scripts
to actually execute.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Update remaining __moltbot__ references in canvas skill documentation
to match the CANVAS_HOST_PATH constant (/__openclaw__/canvas).
* Docs: Direct link to BotFather on Telegram, sparing users from searching and potentially encountering impostors.

* Update numbering syntax

Update numbering syntax to match PR to latest doc layout.

* Docs: add BotFather verification note

---------

Co-authored-by: Sebastian <sebslight@gmail.com>
* docs: add device pairing section to Control UI docs

Explains that new browser connections require one-time pairing approval,
what error message users will see, and how to approve devices using the
CLI. This was a gap in the documentation that caused confusion for users
connecting via Tailscale Serve.

* docs: clarify Control UI pairing error

* docs: clarify device revoke flags

---------

Co-authored-by: Lucifer (via OpenClaw) <lucy@neuwirth.cc>
Co-authored-by: Sebastian <sebslight@gmail.com>
…enclaw#4502)

Co-authored-by: Jarvis <jarvis@openclaw.ai>
Co-authored-by: CLAWDINATOR Bot <clawdinator[bot]@users.noreply.github.com>
Co-authored-by: Shadow <shadow@openclaw.ai>
* docs(discord): clarify exec approvals UI

* Add link for slash command in Discord exec approvals

Updated documentation to include a link for the slash command used in Discord exec approvals.

* docs(discord): move exec approvals note

* docs(discord): document exec approvals config

* docs(discord): reorder exec approvals config

---------

Co-authored-by: Luke K (pr-0f3t) <2609441+lc0rp@users.noreply.github.com>
Co-authored-by: hansbbans <hansbbans@users.noreply.github.com>
- Fix @1 -> $1 in landpr.md
- Fix $@ -> $1 in reviewpr.md
- Remove stray /reviewpr line from reviewpr.md
- Delete old pr.md (replaced by reviewpr.md and landpr.md)
* improve exe.dev setup instructions

1. Fix device approval command
2. Clarify where Gateway token can be found

* Update device approval instructions in exe-dev.md

Clarify instructions for approving devices in OpenClaw.
vignesh07 and others added 25 commits February 2, 2026 23:45
The previous migration to tsdown was reverted because it caused a ~20x slowdown when running OpenClaw from the repo. @hyf0 investigated and found that simply renaming the `dist` folder also caused the same slowdown. It turns out the Plugin script loader has a bunch of voodoo vibe logic to determine if it should load files from source and compile them, or if it should load them from dist. When building with tsdown, the filesystem layout is different (bundled), and so some files weren't in the right location, and the Plugin script loader decided to compile source files from scratch using Jiti.

The new implementation uses tsdown to embed `NODE_ENV: 'production'`, which we now use to determine if we are running OpenClaw from a "production environmen" (ie. from dist). This removes the slop in favor of a deterministic toggle, and doesn't rely on directory names or similar.

There is some code reaching into `dist` to load specific modules, primarily in the voice-call extension, which I simplified into loading an "officially" exported `extensionAPI.js` file. With tsdown, entry points need to be explicitly configured, so we should be able to avoid sloppy code reaching into internals from now on. This might break some existing users, but if it does, it's because they were using "private" APIs.
…nsolidation

Implements a scheduled, offline-first Sleep System that runs during user inactivity:

Shallow Sleep (Maintenance):
- Config validation and integrity checks
- Credential expiry detection
- Integration connectivity probes
- Update checks (OpenClaw, dependencies, tools)
- Security scans (npm audit, credential patterns)
- Development radar (new models, protocol updates)

Deep Sleep (Memory Consolidation):
- Memory pruning (remove stale chunks)
- Memory compaction (summarize sessions)
- Medium-term memory processing
- Long-term memory promotion
- Core memory extraction (identity-shaping patterns)

Memory Hierarchy:
- Short-term: Daily interactions (pruned during sleep)
- Medium-term: Searchable context (promoted on reinforcement)
- Long-term: Auto-loaded stable facts
- Core: Identity-shaping behavioral patterns

Configuration via agents.defaults.sleep with customizable:
- Sleep window (default: 03:00-06:00)
- Idle requirements (default: 45 minutes)
- Task toggles and thresholds

Includes:
- Full documentation (docs/gateway/sleep.md)
- Unit tests (51 tests passing)
- Type-safe config with Zod validation
- Add LLM reflection layer for identity-aware memory evaluation
- Include SOUL.md, IDENTITY.md, core/long-term memories in LLM context
- Store memories in workspace (MEMORIES-CORE.md, MEMORIES-LONG.md)
- Use claude-opus-4-5 by default for high-quality reasoning
- Add config: sleep.deep.llmReflection with provider, model, thresholds
- Integrate LLM reflection as Phase 6 in deep sleep
- Memory tier markdown files now contain clean single-line entries
- Each line has a brief 'why' label (Preference, Value, Pattern, etc)
- No metadata, timestamps, or confidence scores in MD (context-friendly)
- Full metadata stored in separate JSON files for sleep processing
- JSON files live in memory/ dir alongside medium-term markdown
- Updated docs with new file structure and linking tip
Follow same pattern as core/long-term:
- memories-medium.md: clean single-line list for search
- memories-medium.json: full metadata for sleep processing

All memory tier files now have consistent format.
- workspace-sync.test.ts: tests for MD/JSON file generation
- phases.test.ts: tests for shallow and deep sleep phases
- Verifies clean markdown format, JSON metadata, round-trip integrity
- Tests abort handling and phase execution
- memory-conversion.test.ts: JSON→MD with reason/why explanations
- shallow-health.test.ts: credential expiry and version detection
- e2e.test.ts: full sleep cycle tests
- Updated types to include reason field for core/long-term memories
- Updated prompts to request reason for core memory synthesis
New tasks for shallow sleep:
- api-key-validation: Validates API keys by making lightweight requests to
  provider endpoints (Anthropic, OpenAI, Google, Groq, Together, etc.)
- system-dependencies: Checks brew packages, OS updates, Node/Git versions,
  and essential CLI tools (curl, jq, sqlite3)

Config additions:
- tasks.apiKeyValidation: Enable live API key testing
- updates.checkSystemDependencies: Enable brew/OS/tool version checks

Tests:
- api-system-tasks.test.ts: 16 tests for new tasks
- Integration tests verify tasks run in shallow sleep

Total sleep tests: 112 passing
- Add gracePeriodHours, maxPrunePercentPerCycle, fuzziness to pruner
- Add minAgeHoursForPromotion, maxPromotePercentPerCycle to promoter
- Add maxPerCycle limit to core memory extraction
- Expand API key validation for tools (Brave, Firecrawl, ElevenLabs, Perplexity)
- Add skill API key validation from config
- Add rate limit parsing from response headers
- Add doctor integration task (state, security, config checks)
- Add package manager task (outdated, audit)
- Update docs with new safeguard config options
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.