fix(hooks): skip capturing memory_* MCP tools and add capture config env vars#994
fix(hooks): skip capturing memory_* MCP tools and add capture config env vars#994joyjit wants to merge 2 commits into
Conversation
…env vars Closes rohitg00#993. post-tool-use and post-tool-failure now filter agentmemory's own MCP tools (memory_*, ToolSearch, etc.) so recall/search calls are not written back into the observation store. Adds AGENTMEMORY_CAPTURE_DENY/ALLOW, AGENTMEMORY_CAPTURE_OUTPUT_MAX, and AGENTMEMORY_PRE_COMPACT_BUDGET.
|
@joyjit 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)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new ChangesConfigurable Tool Capture Filter
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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/post-tool-use-capture.test.ts`:
- Around line 42-57: The observe assertions in the test are relying on fixed
sleeps after the fire-and-forget fetch from the hook script, which makes the
test flaky. Update the test setup around startServer and the observe call checks
to wait on an explicit server-side signal from the request handler, or use a
bounded polling helper, so the assertions do not depend on scheduler timing.
Make the change consistently in the shared test flow that exercises the observe
request, including the repeated sections noted in the comment.
🪄 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: 55e767f3-ff15-4ed3-b5a2-cca6f54d15fa
📒 Files selected for processing (9)
plugin/scripts/post-tool-failure.mjsplugin/scripts/post-tool-use.mjsplugin/scripts/pre-compact.mjssrc/hooks/_capture-filter.tssrc/hooks/post-tool-failure.tssrc/hooks/post-tool-use.tssrc/hooks/pre-compact.tstest/capture-filter.test.tstest/post-tool-use-capture.test.ts
Address CodeRabbit review on rohitg00#994 — integration test now resolves when the mock server receives /observe (or confirms none arrive after hook exit).
Summary
Fixes #993.
post-tool-useandpost-tool-failurenow skip agentmemory's own MCP tools (memory_*, plus plumbing likeToolSearch) so recall/search calls are not written back into the observation store.AGENTMEMORY_CAPTURE_DENY— extra comma/whitespace-separated deny patterns (default deny includesmemory_*and plumbing tools even when unset)AGENTMEMORY_CAPTURE_ALLOW— if set, only listed tools are captured (overrides deny defaults)AGENTMEMORY_CAPTURE_OUTPUT_MAX— per-observation output cap (default8000)AGENTMEMORY_PRE_COMPACT_BUDGET—/agentmemory/contextbudget on/compact(default1500;0disables injection)Test plan
vitest run test/capture-filter.test.ts test/post-tool-use-capture.test.tsmemory_*MCP tool names are skipped by default (includingmcp__agentmemory__*prefixed forms)Bash,Edit, etc.) still captured/observePOST for filtered toolsSummary by CodeRabbit
New Features
Bug Fixes
Tests