fix(openclaw): scope recall and capture by project#598
Conversation
|
@MackDing is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds helpers to derive a project identifier from several OpenClaw event fields and propagates that project into /agentmemory smart-search (before_agent_start) and /agentmemory/observe (agent_end) payloads; includes Vitest tests validating propagation and fallback behavior. ChangesOpenClaw Project Scoping
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/openclaw-project-scope.test.ts`:
- Around line 34-40: The test setup deletes process.env["AGENTMEMORY_SECRET"] in
beforeEach but never restores it, risking state leakage; modify the setup to
capture the original value (e.g., const originalAgentMemorySecret =
process.env["AGENTMEMORY_SECRET"] or similar) before deleting in beforeEach and
then restore process.env["AGENTMEMORY_SECRET"] = originalAgentMemorySecret (or
delete it if undefined) in afterEach alongside restoring globalThis.fetch =
originalFetch; update the beforeEach/afterEach blocks in
test/openclaw-project-scope.test.ts to use these variables.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 18de1097-da1a-4435-85e1-83a08def6653
📒 Files selected for processing (2)
integrations/openclaw/plugin.mjstest/openclaw-project-scope.test.ts
|
Quick update: I addressed the CodeRabbit test-isolation comment by restoring |
Summary
smart-searchprojectandcwdon OpenClaw observe payloads so captured sessions are grouped consistentlyProblem
The OpenClaw integration recalled memory using only the prompt text and captured turns with only a session id. In shared agentmemory deployments, that makes it too easy for the OpenClaw plugin to query global memory without any project/workspace scoping.
Fix
This PR keeps the change deliberately small and backward-compatible:
before_agent_startnow derives a project value from the OpenClaw event (project, nested workspace metadata, or cwd fallback) and passes it to/agentmemory/smart-searchagent_endnow includesprojectandcwdin/agentmemory/observeThis is not full principal/tenant isolation, but it is a practical hardening step that restores existing project-based filtering support in the backend and reduces cross-project leakage risk for the OpenClaw integration.
Verification
npm test -- --run test/openclaw-plugin.test.ts test/openclaw-project-scope.test.ts test/integration-plaintext-http.test.tsRefs #596
Summary by CodeRabbit
New Features
Tests