Repository navigation
fix(integrations): reuse an existing OpenClaw project stored elsewhere - #1989
Conversation
The OpenClaw plugin stopped working on Basic Memory 1.0 when its project already existed at a folder other than the configured one. Startup asks bm_project to create the project at projectPath, which defaults to the workspace root. Since #1846, BM refuses a same-name create at a different path with ALREADY_EXISTS. Startup failed, and every tool call, including project listing, failed with it. - projectPath unset: startup looks up a project with the plugin's name and creates it at the stored folder, which BM treats as idempotent. The default has changed between plugin releases, so upgrades hit this. - projectPath set and mismatched: the refusal stands, but it no longer fails startup. Project-scoped calls report it, listing still works, and memory health reports the project as unavailable. Transient tool failures still fail startup so the next call retries them. - Docs: describe how projectPath resolves; BASIC_MEMORY.md wrongly said it defaulted to memoryDir. Regression tests cover both cases against a stubbed BM, the health report, transient-failure retry, and both cases against a real bm mcp. Fixes #1988 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Drew Cain <groksrc@gmail.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: abb2962597
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| command: "list", | ||
| output_format: "json", | ||
| }), | ||
| ).find((project) => project.name.toLowerCase() === name) |
There was a problem hiding this comment.
Select the local project row before adopting its path
When cloud credentials expose identically named projects in multiple workspaces, the first name match need not represent the local project. In project_management.py, _merge_workspace_projects sorts the cloud-default workspace first, but _select_attached_cloud_entry can attach the local path to a later row based on the project's configured workspace. Consequently, this lookup can adopt a cloud-only row's tenant-relative path even when the local project already exists at the workspace root. The subsequent local create then returns ALREADY_EXISTS, disabling previously working memory operations. Select the row carrying the local path for local startup, rather than treating the first merged name match as the target backend's project.
AGENTS.md reference: integrations/openclaw/AGENTS.md:L86-L86
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 6dff6f3.
_merge_workspace_projects (project_management.py:101-200) emits one row per workspace for a name. Only the row that _select_attached_cloud_entry picks carries local_path, and a cloud-only row's path is tenant-relative. The server's create compares against the local project list, so the first name match could send a cloud path to a local create and get ALREADY_EXISTS.
Startup now matches only rows with a non-null local_path and creates at that path. A name that exists only in the cloud falls back to the configured path, which is the pre-PR behavior.
Two regression tests in bm-client.test.ts:
- "adopts the local row, not a cloud-only row of the same name": a cloud-only row sorts first.
- "creates at the default path when only a cloud row has the name".
Both fail on abb2962 and pass now. just package-check-openclaw: 285 pass. The real-bm integration tests for this PR still pass.
There was a problem hiding this comment.
Confirmed with an isolated probe of abb2962: when a cloud-only row preceded a local+cloud row with the same name, startupProjectPath selected the cloud-only path. Commit 6dff6f3 now selects the matching row's local_path, which addresses this finding on code inspection. I have not run the full suite or validated this on a live OpenClaw gateway.
With cloud credentials, bm_project list returns one row per workspace for a project name, sorted by workspace priority. Only the row attached to the local project carries local_path; a cloud-only row's path is tenant-relative. Startup took the first name match, so it could pass a cloud path to a local create, which BM refuses with ALREADY_EXISTS. Match only rows with local_path and create at that path. A name that exists only in the cloud falls back to the configured path, as before. Addresses the Codex review on #1989. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Drew Cain <groksrc@gmail.com>
groksrc
left a comment
There was a problem hiding this comment.
The path-selection finding is addressed in 6dff6f3. One remaining P2 finding concerns calls that explicitly target another project. Validation used isolated probes of the client source with mocked transport; the full suite and a live OpenClaw gateway were not tested.
| args: Record<string, unknown>, | ||
| ): Promise<unknown> { | ||
| await this.waitForStartup() | ||
| if (this.projectSetupError) throw this.projectSetupError |
There was a problem hiding this comment.
[P2] Scope the saved setup refusal to the affected project
This unconditional guard rejects every content call when the plugin's project setup was refused, including calls with an explicit project or project_id targeting a different, healthy project. Listing projects succeeds, but selecting one of those projects still throws the unrelated startup refusal before contacting BM.
I reproduced this with the client source at abb2962: after a mocked ALREADY_EXISTS response during startup, readNote("other", { projectId: "other-project-uuid" }) threw the saved setup error and forwarded zero read calls. The guard remains unconditional in 6dff6f3.
Please apply the saved refusal only to calls targeting the unavailable plugin project, and add coverage showing that reads and writes to an explicitly selected healthy project still reach BM.
There was a problem hiding this comment.
Confirmed and fixed in 5c5d0da.
callTool now throws the saved refusal only when args.project names the plugin's project, matched case-insensitively as BM matches names. Calls that name another project by name or by project_id reach BM. Every callTool call sets args.project, either through routedProject() or through routing().
Writing the requested test turned up a second bug. writeNote treats any ALREADY_EXISTS BmToolError as an existing note. So a write to the refused project told the agent "note already exists" instead of explaining the project problem. The refusal is now thrown as a separate ProjectUnavailableError, whose message names the project and BM's reason. projectUnavailableReason() and the health check still report BM's text.
Coverage, in bm-client.test.ts under "lets calls that name another project through after a refusal":
- After a refused startup,
readNote(..., { projectId })andwriteNote(..., "other-project")both reach BM. - Default-routed and differently-cased plugin-project calls are still refused without contacting BM.
The test fails on 6dff6f3 and passes now. just package-check-openclaw: 286 pass. The real-bm integration tests for this PR pass. The one integration failure is the Memory Quest text assertion, which fails on main too (noted in the PR description). Still not run on a live OpenClaw gateway.
After BM refused the plugin's project at startup, every content call threw that refusal, including calls naming another healthy project by name or id. The guard now applies only to calls routed to the plugin's project, matched case-insensitively as BM matches names. The refusal is now thrown as ProjectUnavailableError instead of the raw BmToolError. writeNote reads an ALREADY_EXISTS BmToolError as an existing note, so a write to the refused project reported "note already exists" instead of the project problem. Addresses the second review finding on #1989. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Drew Cain <groksrc@gmail.com>
|
Verified on a live OpenClaw gateway: the old build reproduces #1988, and this PR's build ( Setup. The tests ran on drew-tests with OpenClaw 2026.10.9 and
Before: the old plugin build. The bug reproduces.
After: this PR's build, same config.
Explicit
Not covered. The cloud-row selection from the first review finding was tested only against stubbed project lists, not against a real cloud account. Seen, not changed. The gateway's original config is restored. The PR build is still installed on drew-tests. |
Fixes #1988. With this change, the OpenClaw plugin starts on Basic Memory 1.0 when its project already exists in a different folder. Before, every plugin tool failed, including reads and
list_memory_projects.The bug
At startup the plugin calls
bm_project(command="create")with its project name andprojectPath.projectPathdefaults to the workspace root. Since #1846, BM refuses a same-name create at a different path withALREADY_EXISTS. Before #1846 it reused the project by name.The refusal failed startup. Every tool call waits on startup, and the retry sent the same create, so every tool call failed. The default
projectPathhas changed between plugin releases ("."and~/.basic-memory/openclaw/), so upgrading can trigger this with no config change.What changes
projectPathnot set (bm-client.ts,startupProjectPath): startup lists projects. If a row with the plugin's name has alocal_path, it creates the project at that folder, which BM treats as idempotent. Cloud-only rows are skipped, because their paths are tenant-relative. One info line names the folder used.projectPathset and mismatched: the plugin keeps the refusal, because the user chose that path. The refusal no longer fails startup:ProjectUnavailableErrorcarrying the refusal, which names both paths. Calls that name another project, by name or byproject_id, still reach BM. It isn't aBmToolError, becausewriteNotewould read itsALREADY_EXISTSas an existing note.listProjectsandlistWorkspacesstill work, so the user can see where the project is stored.health()reportsunavailablewith the refusal text, instead ofready.config.tsgainsprojectPathConfigured, which tells the default apart from an explicit".".BASIC_MEMORY.mdnow describe howprojectPathresolves.BASIC_MEMORY.mdwrongly said it defaulted tomemoryDirand had to be absolute.Regression tests
bm-client.test.ts, "an existing project at another folder":basic-memory-capability.test.ts: health reports the refused project as unavailable.integration/bm-client.integration.test.ts: the same two startup cases against a realbm mcpfrom this checkout, so they exercise fix(mcp): refuse create_memory_project path mismatch #1846's server-side refusal.The three regression unit tests fail when run against the old
bm-client.tsand capability code, and pass with this change.Verification
just package-check-openclaw: exit 0, 286 tests pass (typecheck, lint, build,npm pack --dry-run).bun run test:int(realbm mcp): both new tests pass."Note already exists", but the tool now returns"A note already exists at ...". It fails the same way with this PR's source changes reverted, and this PR doesn't touchtools/. CI doesn't run the integration suite, which is probably why nobody has noticed.5c5d0da6andbm1.0.0. The old build reproduces the bug, and this build fixes it. Details are in the PR comment with the live results.🤖 Generated with Claude Code