Skip to content

fix(memory): use canonical workspace for system agent shared memory - #136767

Closed
xmoxmo wants to merge 6 commits into
openclaw:mainfrom
xmoxmo:fix/memory-canonical-shared-workspace-8.2
Closed

xmoxmo wants to merge 6 commits into
openclaw:mainfrom
xmoxmo:fix/memory-canonical-shared-workspace-8.2

Conversation

@xmoxmo

@xmoxmo xmoxmo commented Sep 3, 2026

Copy link
Copy Markdown

Summary

When the system agent is configured with an explicit default workspace (), the memory runtime and memory-core manager now use that path directly for the shared memory database instead of resolving to a per-agent subdirectory.

This fixes the shared memory database being keyed from different workspace paths depending on whether it is accessed through the runtime plugin loader () or the memory-core CLI/agent manager (). Without this change, the system agent scans while the shared store is keyed from the default workspace, overwriting shared source state.

Changes

  • src/plugins/memory-runtime.ts: When agentId === systemAgentId and agents.defaults.workspace is configured, resolve the workspace from the default workspace path (handling ~ expansion) instead of calling resolveAgentWorkspaceDir.
  • extensions/memory-core/src/memory/manager.ts: Add resolveSharedMemoryManagerWorkspaceDir helper with the same canonical workspace rule, used by MemoryIndexManager.get() for CLI and agent-spawned memory operations.

Motivation

Multi-agent deployments that set agents.defaults.systemAgent.agentId and agents.defaults.workspace expect the system agent's memory to live in the configured default workspace. The current code resolves the system agent to a workspace/<agentId> subdirectory, creating a mismatch between the plugin lifecycle path and the manager path. This leads to duplicate databases, stale indexes, and shared source state being overwritten.

Testing

  • Local test suite requires @openclaw/fs-safe >= 0.5.x (the 8.2 dependency version); the current node_modules snapshot predates this dependency and cannot run vitest locally. CI will validate the full suite.
  • Manual verification: the canonical workspace patch monitor confirms both the runtime and manager paths use the same resolved workspace for the system agent.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 3, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

The branch redirects system-agent memory loading and indexing to the default workspace, adds OS-home expansion, and includes inherited release-preparation changes.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The motivation is useful, but two established correctness defects and unverified runtime and upgrade behavior prevent readiness.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 11 items remain

Keep open: both prior correctness findings remain, and no verified merged replacement establishes that this work is complete. The same-author shared-index proposal remains open but is not a safe supersession target.

Priority: P2
Reviewed head: f78940982dc3dfbd85e984627707f38ed1466128

Before merge

  • Add real behavior proof - The captured patch-monitor assertion does not show the changed runtime loader and Memory Core manager indexing and reading the intended files in a real setup. Existing-index compatibility is also unproven because workspace scope changes within the retained agent database. Provide redacted terminal output, logs, or diagnostic media; remove private paths, endpoints, and credentials. Updating the PR body should trigger review, otherwise ask a maintainer for @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve the canonical agent workspace (P1) - With a configured system agent, a default root, and an explicit per-agent workspace, this branch always selects the default root. The canonical resolver honors the explicit workspace first, so memory now indexes and reads different files from the agent’s configured workspace. The runtime bridge repeats the same override. Remove the competing policy and retain canonical resolution; this prior finding remains unfixed.
  • Let the existing resolver expand the effective home (P2) - For ~ or ~/... with OPENCLAW_HOME different from the OS home, pre-expanding with homedir() produces an absolute OS-home path that resolveUserPath can no longer expand against OpenClaw’s effective home. Memory selects the wrong directory. Pass the original path through the canonical resolver; the manager contains the same defect, and the prior finding remains unfixed.
  • Resolve merge risk - Existing-index compatibility is unproven: the new workspace changes the persisted corpus scope while retaining the agent database, potentially replacing indexed source state on synchronization.
  • Resolve merge risk - The conflicting branch includes inherited release, dependency, and generated-output work beyond the memory repair; a refreshed, focused candidate is needed to establish its actual merge scope.
  • Resolve merge risk - The memory repair adds 31 net production lines by duplicating workspace policy; the existing canonical resolver can absorb the intended behavior without these competing branches.
  • Complete next step - Address both workspace findings, isolate the memory change on a conflict-free branch, and add real runtime plus existing-index compatibility evidence before merge.
  • Improve patch quality - Restore canonical workspace selection and cover explicit overrides plus OPENCLAW_HOME behavior.
  • Improve patch quality - Provide real indexing/read observations and prove compatibility with an existing populated index.
  • Improve patch quality - Refresh the conflicting branch to isolate the memory change from inherited release work.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Preserve the canonical agent workspace — extensions/memory-core/src/memory/manager.ts:91-95
  • [P2] Let the existing resolver expand the effective home — src/plugins/memory-runtime.ts:108-110
Agent review details

How this fits together

OpenClaw’s memory runtime loads the selected memory plugin; Memory Core then indexes and reads files from the agent’s workspace. Workspace selection affects the indexed corpus, while database ownership is separately resolved from the agent identity.

flowchart TD
  A[Agent configuration] --> B[Workspace resolver]
  A --> C[Memory plugin loader]
  B --> C
  C --> D[Memory Core manager]
  B --> D
  E[Agent database identity] --> D
  D --> F[Indexed workspace files]
  F --> G[Memory search and reads]
Loading

Technical review

Best possible solution:

Use one canonical workspace resolver, preserve explicit agent settings and effective-home semantics, and keep shared-index ownership inside Memory Core with verified existing-state behavior.

Do we have a high-confidence way to reproduce the issue?

Yes, for the introduced defects: configure a system agent with an explicit workspace different from the default root, or use a tilde default with OPENCLAW_HOME different from the OS home. Source establishes the wrong selection; no runtime reproduction was executed.

Is this the best way to solve the issue?

No. The patch duplicates supported workspace selection and leaves database ownership agent-scoped; explicit workspace configuration already provides root selection, while genuine index sharing needs a Memory Core-owned design.

Full review comments:

  • [P1] Preserve the canonical agent workspace — extensions/memory-core/src/memory/manager.ts:91-95
    With a configured system agent, a default root, and an explicit per-agent workspace, this branch always selects the default root. The canonical resolver honors the explicit workspace first, so memory now indexes and reads different files from the agent’s configured workspace. The runtime bridge repeats the same override. Remove the competing policy and retain canonical resolution; this prior finding remains unfixed.
    Confidence: 0.99
  • [P2] Let the existing resolver expand the effective home — src/plugins/memory-runtime.ts:108-110
    For ~ or ~/... with OPENCLAW_HOME different from the OS home, pre-expanding with homedir() produces an absolute OS-home path that resolveUserPath can no longer expand against OpenClaw’s effective home. Memory selects the wrong directory. Pass the original path through the canonical resolver; the manager contains the same defect, and the prior finding remains unfixed.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against cb04039f21de.

Merge-risk options

Maintainer options:

  1. Restore canonical workspace ownership (recommended)
    Remove the memory-specific workspace branches and refresh the focused candidate with regression and existing-index proof.
  2. Consolidate shared-index work
    Coordinate this proposal with the same-author shared-index PR without treating that unmerged, unproven branch as a completed replacement.

Security

None.

Evidence

What I checked:

  • Pinned introduction and parentage: The pinned merge-base-to-head diff contains both workspace overrides. Raw head parentage identifies 3928bad as the recorded parent; its head-to-parent delta isolates the two memory files from inherited release work. (extensions/memory-core/src/memory/manager.ts:85, f78940982dc3)
  • Introduced workspace override: Both new branches select agents.defaults.workspace before consulting the canonical resolver, including when the system agent has its own explicit workspace. (extensions/memory-core/src/memory/manager.ts:91, f78940982dc3)
  • Canonical workspace contract on current main: Current main honors the per-agent workspace first, preserves the named legacy owner’s inherited root, and otherwise nests unpinned agents beneath the default root. Its memory loader and Memory Core manager use that resolver. (src/agents/agent-scope-config.ts:461, cb04039f21de)
  • Existing supported configuration: The workspace documentation states that a shared default root does not assign that root to an agent; explicitly pinning agents.entries.main.workspace provides the supported root-selection path. Public docs: docs/concepts/agent-workspace.md. (docs/concepts/agent-workspace.md:42, f78940982dc3)
  • Effective-home contract and tests: resolveUserPath already expands tilde using OPENCLAW_HOME before OS-home sources. The inspected home-directory tests explicitly expect ~/docs beneath the configured effective home. (src/infra/home-dir.ts:147, f78940982dc3)
  • Database ownership and persisted index identity: Memory search settings derive databasePath from resolveOpenClawAgentSqlitePath(agentId), independently of workspaceDir. The manager uses that database while its index identity incorporates workspaceDir, so changing the root changes the corpus identity without implementing shared database ownership. (src/agents/memory-search.ts:306, f78940982dc3)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus test delta Production/tooling +61/-16, net +45; tests/support +378/-88, net +290; generated metadata, docs, and locks counted separately The two memory files account for net +31 production lines and add no focused regression coverage; their duplicated resolver policy is avoidable.
Workspace policy 2 consumer-specific overrides added Both bypass the existing resolver without changing agent-scoped database ownership.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The proposal affects configured system-agent memory with a bounded blast radius; check failures do not independently increase priority.
  • merge-risk: 🚨 compatibility: The introduced branches override explicit workspace preferences and change tilde expansion for existing configurations.
  • merge-risk: 🚨 session-state: Changing the workspace scope within the retained agent database can replace the indexed memory corpus, without upgrade proof.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-03T00:47:20.251Z sha 6ef219932ca70dc82798dcd439f6ad46a1b525eb :: needs real behavior proof before merge. :: [P1] Preserve the canonical agent workspace
  • reviewed 2026-09-06T10:16:15.201Z sha f789409 :: needs real behavior proof before merge. :: [P1] Preserve the canonical agent workspace | [P2] Let the existing path resolver expand the effective home
  • reviewed September 22, 2026, 6:48 PM ET / 22:48 UTC (Revision 3) sha unknown :: needs real behavior proof before merge. :: [P1] Preserve the canonical agent workspace | [P2] Let the existing resolver expand the effective home

Reviewed October 7, 2026, 10:40 AM ET / 14:40 UTC (Revision 4).

steipete and others added 6 commits September 5, 2026 04:38
Regenerate release package versions, official channel metadata, and UI/native
locales from main b6a2e5b.

Validated canonical release preparation, full generated checks, 20 UI locales,
21 native locales, production UI asset budgets, and independent P0-P2 review.
Backport the reviewed hardware scan inventory and exact release/2026.9.2
registration from openclaw#139046, preserving the frozen 2026.9.1 policy.

Backport Undici 8.10.2/7.29.1, the approved version-specific overrides and
cooldown exceptions, paired NO_PROXY normalization, and locked release
toolchain digests from openclaw#139056.

Validated 31 scanner/hardware tests, 205 proxy/guard/dispatcher tests, frozen
dependency installation, full build and SDK/UI budgets, and independent
P0-P2 review. Both patches match their canonical main landings.

(cherry picked from commit 9010252)
(cherry picked from commit d7a1753)
Lead with performance, reliability, and GPT-6 Astra support. Regenerate the
complete contribution record from release history, preserving source refs,
161 credited contributors, and unchanged historical release notes.

Verified 1,239 PR records, source packaging, full GitHub rendering, and
independent P0-P2 review.
Backport the verified main repairs for update ledger isolation, Matrix client
cleanup, paired client metadata, task cancellation, Telegram timer ownership,
Claude adapter version resolution, MCP runtime leases, and native update/node
E2E execution. Preserve strict assertions and authenticated routing contracts.

Let stable malformed database bytes reach SQLite diagnostics through the
existing verified private snapshot path. Keep the frozen worker interface;
no schema, configuration, or stored representation changes.

Match the Apple localization assertion to the release-generated Watch copy.
The Watch Rust workflow correction is supplied separately by trusted tooling.

(cherry picked from commit bcecb3d)
(cherry picked from commit df78d38)
(cherry picked from commit a20dbd7)
(cherry picked from commit 48406f2)
(cherry picked from commit b8f23d0)
(cherry picked from commit a9f5e44)
(cherry picked from commit 3383007)
(cherry picked from commit d93fb26)

Co-authored-by: Vincent Koc <[email protected]>
Lead with performance, reliability, and GPT-6 Astra support. Preserve the
complete canonical contribution record and source-reviewed SDK guidance.
When the system agent is configured with an explicit default workspace
(agents.defaults.workspace), use that path directly for the shared
memory database instead of the per-agent subdirectory. This ensures the
system agent and the memory plugin lifecycle share the same canonical
workspace and SQLite database.

Applies to both the runtime plugin loader (memory-runtime.ts) and the
memory-core CLI/agent manager (manager.ts).
@xmoxmo
xmoxmo force-pushed the fix/memory-canonical-shared-workspace-8.2 branch from 6ef2199 to f789409 Compare September 6, 2026 10:09
@xmoxmo
xmoxmo requested a review from a team as a code owner September 6, 2026 10:09
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • .github/release/clawhub-cli/package-lock.json
  • .github/release/vercel-cli/package-lock.json
  • extensions/acpx/package.json
  • extensions/amazon-bedrock/package.json
  • extensions/anthropic-vertex/package.json
  • extensions/cua-computer/package.json
  • extensions/discord/package.json
  • extensions/google/package.json
  • extensions/matrix/package.json
  • extensions/memory-lancedb/package.json
  • extensions/reef/package.json
  • extensions/slack/package.json
  • extensions/tlon/package.json
  • package.json
  • packages/ai/package.json
  • pnpm-lock.yaml
  • pnpm-workspace.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfiles or workspace dependency policy changes are present.
  • Treat pnpm-lock.yaml and package-lock.json diffs as dependency security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Dependency graph changes are blocked

OpenClaw does not accept dependency graph changes through PRs unless a repository admin or security explicitly authorizes the current head SHA. Dependency updates are generated internally by maintainers so external PRs cannot change the resolved graph.

Detected dependency graph changes:

  • .github/release/clawhub-cli/package-lock.json changed.
  • .github/release/vercel-cli/package-lock.json changed.
  • pnpm-lock.yaml changed.
  • extensions/acpx/package.json changed dependencies.
  • extensions/amazon-bedrock/package.json changed dependencies.
  • extensions/anthropic-vertex/package.json changed dependencies.
  • extensions/cua-computer/package.json changed dependencies.
  • extensions/discord/package.json changed dependencies.
  • extensions/google/package.json changed dependencies.
  • extensions/matrix/package.json changed dependencies.
  • extensions/memory-lancedb/package.json changed dependencies.
  • extensions/reef/package.json changed dependencies.
  • extensions/slack/package.json changed dependencies.
  • extensions/tlon/package.json changed dependencies.
  • package.json changed dependencies, devDependencies, packageManager.
  • packages/ai/package.json changed dependencies.

Auto-scrub was not attempted because this PR changes package manifest dependency graph fields:

  • extensions/acpx/package.json changed dependencies.
  • extensions/amazon-bedrock/package.json changed dependencies.
  • extensions/anthropic-vertex/package.json changed dependencies.
  • extensions/cua-computer/package.json changed dependencies.
  • extensions/discord/package.json changed dependencies.
  • extensions/google/package.json changed dependencies.
  • extensions/matrix/package.json changed dependencies.
  • extensions/memory-lancedb/package.json changed dependencies.
  • extensions/reef/package.json changed dependencies.
  • extensions/slack/package.json changed dependencies.
  • extensions/tlon/package.json changed dependencies.
  • package.json changed dependencies, devDependencies, packageManager.
  • packages/ai/package.json changed dependencies.

Dependency graph changes must be reviewed by security or handled by maintainers internally. Please remove lockfile changes manually if they are not needed.

To remove lockfile changes, restore them from the target branch:

git fetch origin
git checkout 'origin/main' -- '.github/release/clawhub-cli/package-lock.json' '.github/release/vercel-cli/package-lock.json' 'pnpm-lock.yaml'
git commit -m 'chore: remove dependency lockfile change'
git push

If this PR intentionally needs a dependency graph change, ask a repository admin or member of @openclaw/openclaw-secops to comment:

/allow-dependencies-change

The action will approve the current head SHA (f78940982dc3dfbd85e984627707f38ed1466128) when it reruns. A later push requires a fresh approval.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@vincentkoc

Copy link
Copy Markdown
Member

Thanks for the shared-memory workspace work. We are closing this stale proposal as part of maintainer backlog cleanup. This closure does not establish that the originally reported workspace mismatch is fixed. If it remains reproducible on current main, please bring a focused report or change against the current memory owner paths.

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

Labels

agents Agent runtime and tooling app: ios App: ios app: macos App: macos app: web-ui App: web-ui channel: a2a channel: buzz channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: irc channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: qa-channel Channel integration: qa-channel channel: raft Channel integration: Raft channel: reef Channel integration: reef channel: signal Channel integration: signal channel: slack Channel integration: slack channel: sms Channel integration: sms channel: synology-chat channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: twitch Channel integration: twitch channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser docker Docker and sandbox tooling docs Improvements or additions to documentation extensions: acpx extensions: admin-http-rpc extensions: anthropic extensions: arcee extensions: baseten Extension: baseten extensions: byteplus extensions: cerebras extensions: clawrouter Extension: clawrouter extensions: clickclack extensions: cloudflare-ai-gateway extensions: cohere extensions: comfy extensions: copilot-proxy Extension: copilot-proxy extensions: crabbox extensions: deepgram extensions: deepinfra extensions: deepseek extensions: diagnostics-otel Extension: diagnostics-otel extensions: diagnostics-prometheus extensions: document-extract extensions: duckduckgo extensions: featherless extensions: gmi extensions: huggingface extensions: llama-cpp extensions: llm-task Extension: llm-task extensions: lobster Extension: lobster extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb extensions: memory-wiki extensions: oc-path extensions: onepassword 1Password plugin extensions: policy extensions: qa-lab extensions: stepfun extensions: tencent extensions: tokenjuice Changes to the bundled tokenjuice extension extensions: vault Extension: vault extensions: web-readability extensions: webhooks gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. plugin: azure-speech Azure Speech plugin plugin: beam Beam session sharing plugin plugin: bonjour Plugin integration: bonjour plugin: cua-computer plugin: file-transfer plugin: geolocation Geolocation plugin (IP to coarse city) plugin: google-meet plugin: imap plugin: linux-node plugin: logbook Logbook automatic work journal plugin plugin: migrate-claude plugin: migrate-hermes plugin: mxc plugin: pixverse plugin: teams-meetings Teams Meetings plugin plugin: visitor-access plugin: workboard plugin: zoom Zoom plugin rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants