Add tested Pi/OpenClaw/Hermes integration fixes#230
Conversation
|
@deepmroot is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThis PR restructures agentmemory integrations across multiple agents (Hermes, OpenClaw, pi) from MCP-only to a unified plugin architecture. It adds plugin manifests, refactors existing implementations, introduces a new pi TypeScript extension, and updates all documentation to reflect the new memory plugin setup patterns and corrected tool counts. ChangesMemory Plugin Integration Layer
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes The PR spans diverse changes across three agent integrations with varying complexity: new plugin schema definition, provider endpoint update, significant plugin logic refactor (switching from class to object pattern with altered hook behavior), brand-new 260+ line TypeScript extension with stateful session tracking and async operations, multiple new package manifests, and comprehensive documentation updates. The heterogeneous nature of implementation changes across languages (Python, JavaScript, TypeScript) and the semantic shift from MCP-only to plugin-based approach requires careful review of each integration's correctness and consistency. Possibly related PRs
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)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
README.md (1)
605-607:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winInconsistent tool count within MCP Server section.
Line 605 states "51 tools" but the section header on line 607 says "### 50 Tools". One of these should be corrected for consistency.
-51 tools, 6 resources, 3 prompts, and 4 skills — the most comprehensive MCP memory toolkit for any agent. +50 tools, 6 resources, 3 prompts, and 4 skills — the most comprehensive MCP memory toolkit for any agent.Or update the header to match:
-### 50 Tools +### 51 Tools🤖 Prompt for 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. In `@README.md` around lines 605 - 607, Update the inconsistent tool count by making the two mentions match: either change the summary text "51 tools, 6 resources, 3 prompts, and 4 skills" to "50 tools, 6 resources, 3 prompts, and 4 skills" or update the section header "### 50 Tools" to "### 51 Tools" so both the summary string and the header ("51 tools, 6 resources, 3 prompts, and 4 skills" and "### 50 Tools") consistently reflect the correct total.
🧹 Nitpick comments (2)
integrations/pi/index.ts (2)
147-154: 💤 Low valueHardcoded URL in error message may mislead users.
The error message hardcodes
http://localhost:3111, but the actual URL could be overridden viaAGENTMEMORY_URL. Consider using the resolved URL.♻️ Proposed fix
async execute() { + const baseUrl = normalizeBaseUrl(process.env.AGENTMEMORY_URL || DEFAULT_URL); const health = await getHealth(); if (!health) { return { - content: [{ type: "text", text: "agentmemory is unreachable at http://localhost:3111" }], + content: [{ type: "text", text: `agentmemory is unreachable at ${baseUrl}` }], details: { ok: false }, }; }🤖 Prompt for 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. In `@integrations/pi/index.ts` around lines 147 - 154, The error message in execute() hardcodes "http://localhost:3111"; update the unreachable response to use the resolved Agent Memory URL (the AGENTMEMORY_URL env/config value or whatever URL getHealth() uses) instead of the literal string so the message reflects the actual endpoint; locate execute() and the getHealth() call and replace the hardcoded URL in the returned content with the same resolved URL variable (e.g., AGENTMEMORY_URL or the helper that computes the agent memory URL).
83-109: ⚡ Quick winConsider adding a timeout to prevent hanging requests.
The Hermes integration uses a 5-second timeout (
TIMEOUT = 5), but thisfetchcall has no timeout. Long-hanging requests could delaybefore_agent_startor cause unresponsive behavior if the server is slow or unreachable.♻️ Proposed fix using AbortSignal
async function callAgentMemory<T>( pathname: string, options?: { method?: "GET" | "POST"; body?: unknown; baseUrl?: string; + timeoutMs?: number; }, ): Promise<T | null> { const baseUrl = normalizeBaseUrl(options?.baseUrl || process.env.AGENTMEMORY_URL || DEFAULT_URL); const method = options?.method || "POST"; const url = `${baseUrl}/agentmemory/${pathname.replace(/^\/+/, "")}`; const headers: Record<string, string> = {}; if (options?.body !== undefined) headers["Content-Type"] = "application/json"; if (process.env.AGENTMEMORY_SECRET) headers.Authorization = `Bearer ${process.env.AGENTMEMORY_SECRET}`; try { const response = await fetch(url, { method, headers, body: options?.body !== undefined ? JSON.stringify(options.body) : undefined, + signal: AbortSignal.timeout(options?.timeoutMs ?? 5000), }); if (!response.ok) return null; return (await response.json()) as T; } catch { return null; } }🤖 Prompt for 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. In `@integrations/pi/index.ts` around lines 83 - 109, The callAgentMemory function can hang because fetch has no timeout; update callAgentMemory to use an AbortController with a configurable timeout (match the existing TIMEOUT constant used elsewhere, e.g., TIMEOUT = 5) and abort the request after the timeout; create an AbortController, pass its signal into fetch, set a timer to call controller.abort() after TIMEOUT seconds (clear the timer on success), and ensure the catch block treats abort errors the same (return null) while avoiding unhandled timers or leaks.
🤖 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 `@integrations/openclaw/plugin.mjs`:
- Around line 113-130: Remove the unsupported min_confidence option from the
plugin config and cfg object (and from configSchema if present) and ensure
token_budget is actually sent to the backend by adding it to the payload of the
smart-search call; specifically, update the cfg declaration to omit
min_confidence, keep token_budget from api.pluginConfig, and modify the
client.postJson("/agentmemory/smart-search", { ... }) call in the
before_agent_start handler to include token_budget (using the cfg.token_budget
or api.pluginConfig.token_budget) so the backend receives the parameter.
---
Outside diff comments:
In `@README.md`:
- Around line 605-607: Update the inconsistent tool count by making the two
mentions match: either change the summary text "51 tools, 6 resources, 3
prompts, and 4 skills" to "50 tools, 6 resources, 3 prompts, and 4 skills" or
update the section header "### 50 Tools" to "### 51 Tools" so both the summary
string and the header ("51 tools, 6 resources, 3 prompts, and 4 skills" and "###
50 Tools") consistently reflect the correct total.
---
Nitpick comments:
In `@integrations/pi/index.ts`:
- Around line 147-154: The error message in execute() hardcodes
"http://localhost:3111"; update the unreachable response to use the resolved
Agent Memory URL (the AGENTMEMORY_URL env/config value or whatever URL
getHealth() uses) instead of the literal string so the message reflects the
actual endpoint; locate execute() and the getHealth() call and replace the
hardcoded URL in the returned content with the same resolved URL variable (e.g.,
AGENTMEMORY_URL or the helper that computes the agent memory URL).
- Around line 83-109: The callAgentMemory function can hang because fetch has no
timeout; update callAgentMemory to use an AbortController with a configurable
timeout (match the existing TIMEOUT constant used elsewhere, e.g., TIMEOUT = 5)
and abort the request after the timeout; create an AbortController, pass its
signal into fetch, set a timer to call controller.abort() after TIMEOUT seconds
(clear the timer on success), and ensure the catch block treats abort errors the
same (return null) while avoiding unhandled timers or leaks.
🪄 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: 68097b65-f586-499f-b103-f9a35abd4e85
📒 Files selected for processing (10)
README.mdintegrations/hermes/README.mdintegrations/hermes/__init__.pyintegrations/openclaw/README.mdintegrations/openclaw/openclaw.plugin.jsonintegrations/openclaw/package.jsonintegrations/openclaw/plugin.mjsintegrations/pi/README.mdintegrations/pi/index.tsintegrations/pi/package.json
| const cfg = { | ||
| enabled: api.pluginConfig?.enabled !== false, | ||
| base_url: api.pluginConfig?.base_url || DEFAULT_BASE_URL, | ||
| token_budget: api.pluginConfig?.token_budget || 2000, | ||
| min_confidence: api.pluginConfig?.min_confidence || 0.5, | ||
| fallback_on_error: api.pluginConfig?.fallback_on_error !== false, | ||
| timeout_ms: api.pluginConfig?.timeout_ms || DEFAULT_TIMEOUT_MS, | ||
| }; | ||
| const client = createClient(cfg, api); | ||
|
|
||
| async onPostToolUse(ctx) { | ||
| if (!this.enabled) return; | ||
| await this.postJson("/agentmemory/observe", { | ||
| hookType: "post_tool_use", | ||
| sessionId: ctx.sessionId, | ||
| timestamp: new Date().toISOString(), | ||
| data: { | ||
| tool_name: ctx.toolName, | ||
| tool_input: ctx.toolInput, | ||
| tool_output: ctx.toolOutput, | ||
| }, | ||
| api.on("before_agent_start", async (event) => { | ||
| if (!cfg.enabled) return; | ||
| const prompt = typeof event?.prompt === "string" ? event.prompt.trim() : ""; | ||
| if (!prompt) return; | ||
| const result = await client.postJson("/agentmemory/smart-search", { | ||
| query: prompt, | ||
| limit: 5, | ||
| }); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if smart-search endpoint supports token_budget or min_confidence parameters
rg -n "token_budget|min_confidence" --type=ts -C3 src/Repository: rohitg00/agentmemory
Length of output: 4313
🏁 Script executed:
rg -n "min_confidence" --type=ts -C2Repository: rohitg00/agentmemory
Length of output: 46
🏁 Script executed:
git ls-files "*/openclaw/plugin.mjs" "integrations/*/plugin.mjs"Repository: rohitg00/agentmemory
Length of output: 97
🏁 Script executed:
wc -l integrations/openclaw/plugin.mjsRepository: rohitg00/agentmemory
Length of output: 101
🏁 Script executed:
cat -n integrations/openclaw/plugin.mjs | head -150Repository: rohitg00/agentmemory
Length of output: 6016
min_confidence is unsupported and token_budget is not passed to the API.
min_confidence does not appear in the backend API (agentmemory) and should be removed from the config to avoid confusion. token_budget is a supported parameter but is extracted from pluginConfig yet never passed to the smart-search call.
Update the smart-search call to pass token_budget:
diff
const result = await client.postJson("/agentmemory/smart-search", {
query: prompt,
limit: 5,
+ token_budget: cfg.token_budget,
});Remove min_confidence from configSchema and the cfg object:
diff
const cfg = {
enabled: api.pluginConfig?.enabled !== false,
base_url: api.pluginConfig?.base_url || DEFAULT_BASE_URL,
token_budget: api.pluginConfig?.token_budget || 2000,
- min_confidence: api.pluginConfig?.min_confidence || 0.5,
fallback_on_error: api.pluginConfig?.fallback_on_error !== false,
timeout_ms: api.pluginConfig?.timeout_ms || DEFAULT_TIMEOUT_MS,
}; const configSchema = {
type: "object",
additionalProperties: false,
properties: {
enabled: { type: "boolean" },
base_url: { type: "string" },
token_budget: { type: "number" },
- min_confidence: { type: "number" },
fallback_on_error: { type: "boolean" },
timeout_ms: { type: "number" },
},
};🤖 Prompt for 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.
In `@integrations/openclaw/plugin.mjs` around lines 113 - 130, Remove the
unsupported min_confidence option from the plugin config and cfg object (and
from configSchema if present) and ensure token_budget is actually sent to the
backend by adding it to the payload of the smart-search call; specifically,
update the cfg declaration to omit min_confidence, keep token_budget from
api.pluginConfig, and modify the client.postJson("/agentmemory/smart-search", {
... }) call in the before_agent_start handler to include token_budget (using the
cfg.token_budget or api.pluginConfig.token_budget) so the backend receives the
parameter.
Bug-fix patch focused on search recall correctness and plugin compatibility. Pins iii-engine to v0.11.2 because v0.11.6 introduces a new sandbox-everything-via-`iii worker add` model that agentmemory hasn't been refactored for yet — pin lifts once that refactor lands. Adds a hard guard against silent vector-index corruption, fixes BM25 indexing for memories saved via memory_save, and lands four Hermes plugin fixes. Per AGENTS.md release checklist: - package.json version 0.9.4 -> 0.9.5 - src/version.ts VERSION constant - src/types.ts ExportData version union - src/functions/export-import.ts supportedVersions Set - test/export-import.test.ts assertion - plugin/.claude-plugin/plugin.json version - CHANGELOG.md detailed entries with contributor shoutouts Headlines (full detail in CHANGELOG): Fixed: - BM25 search now indexes memories saved via memory_save (#258, #257) Thanks @Nizar-BenHamida for the precise repro. - Embedding providers no longer silently corrupt the vector index when an API returns wrong-dimension vectors (#248, #247, #256) Thanks @AmmarSaleh50 for issue + fix + tests. - Hermes handle_tool_call returns JSON strings, not raw dicts (#255, #254) Thanks @KyoMio for the Anthropic-protocol repro. - Hermes status reflects real service state on systemd installs (#253, #250) Thanks @OptionalCoin for tracing it to env-source divergence. - Hermes hooks accept passthrough kwargs (#252, #249) Thanks @OptionalCoin again for the log analysis. - agentmemory demo now seeds observations correctly (#251, #229) Thanks @seishonagon for root-cause analysis. - LLM compression / summarization timeouts increased (#213) Thanks @xuli500177. - Pi / OpenClaw / Hermes integration plugin fixes (#230) Thanks @deepmroot. Changed: - iii-engine pinned to v0.11.2 across every install path (#260). v0.11.6 introduces a new `iii worker add` sandbox model that agentmemory still pre-dates; pin lifts when we refactor agentmemory to register as a sandboxed worker. Override with AGENTMEMORY_III_VERSION=<version> for users who've migrated manually. - README documents iii worker add extension surface (#242). - README iii Console install/launch commands corrected (#243). Validated: 852/852 tests pass, npm run build clean.
Bug-fix patch focused on search recall correctness and plugin compatibility. Pins iii-engine to v0.11.2 because v0.11.6 introduces a new sandbox-everything-via-`iii worker add` model that agentmemory hasn't been refactored for yet — pin lifts once that refactor lands. Adds a hard guard against silent vector-index corruption, fixes BM25 indexing for memories saved via memory_save, and lands four Hermes plugin fixes. Per AGENTS.md release checklist: - package.json version 0.9.4 -> 0.9.5 - src/version.ts VERSION constant - src/types.ts ExportData version union - src/functions/export-import.ts supportedVersions Set - test/export-import.test.ts assertion - plugin/.claude-plugin/plugin.json version - CHANGELOG.md detailed entries with contributor shoutouts Headlines (full detail in CHANGELOG): Fixed: - BM25 search now indexes memories saved via memory_save (#258, #257) Thanks @Nizar-BenHamida for the precise repro. - Embedding providers no longer silently corrupt the vector index when an API returns wrong-dimension vectors (#248, #247, #256) Thanks @AmmarSaleh50 for issue + fix + tests. - Hermes handle_tool_call returns JSON strings, not raw dicts (#255, #254) Thanks @KyoMio for the Anthropic-protocol repro. - Hermes status reflects real service state on systemd installs (#253, #250) Thanks @OptionalCoin for tracing it to env-source divergence. - Hermes hooks accept passthrough kwargs (#252, #249) Thanks @OptionalCoin again for the log analysis. - agentmemory demo now seeds observations correctly (#251, #229) Thanks @seishonagon for root-cause analysis. - LLM compression / summarization timeouts increased (#213) Thanks @xuli500177. - Pi / OpenClaw / Hermes integration plugin fixes (#230) Thanks @deepmroot. Changed: - iii-engine pinned to v0.11.2 across every install path (#260). v0.11.6 introduces a new `iii worker add` sandbox model that agentmemory still pre-dates; pin lifts when we refactor agentmemory to register as a sandboxed worker. Override with AGENTMEMORY_III_VERSION=<version> for users who've migrated manually. - README documents iii worker add extension surface (#242). - README iii Console install/launch commands corrected (#243). Validated: 852/852 tests pass, npm run build clean.
Bug-fix patch focused on search recall correctness and plugin compatibility. Pins iii-engine to v0.11.2 because v0.11.6 introduces a new sandbox-everything-via-`iii worker add` model that agentmemory hasn't been refactored for yet — pin lifts once that refactor lands. Adds a hard guard against silent vector-index corruption, fixes BM25 indexing for memories saved via memory_save, and lands four Hermes plugin fixes. Per AGENTS.md release checklist: - package.json version 0.9.4 -> 0.9.5 - src/version.ts VERSION constant - src/types.ts ExportData version union - src/functions/export-import.ts supportedVersions Set - test/export-import.test.ts assertion - plugin/.claude-plugin/plugin.json version - CHANGELOG.md detailed entries with contributor shoutouts Headlines (full detail in CHANGELOG): Fixed: - BM25 search now indexes memories saved via memory_save (#258, #257) Thanks @Nizar-BenHamida for the precise repro. - Embedding providers no longer silently corrupt the vector index when an API returns wrong-dimension vectors (#248, #247, #256) Thanks @AmmarSaleh50 for issue + fix + tests. - Hermes handle_tool_call returns JSON strings, not raw dicts (#255, #254) Thanks @KyoMio for the Anthropic-protocol repro. - Hermes status reflects real service state on systemd installs (#253, #250) Thanks @OptionalCoin for tracing it to env-source divergence. - Hermes hooks accept passthrough kwargs (#252, #249) Thanks @OptionalCoin again for the log analysis. - agentmemory demo now seeds observations correctly (#251, #229) Thanks @seishonagon for root-cause analysis. - LLM compression / summarization timeouts increased (#213) Thanks @xuli500177. - Pi / OpenClaw / Hermes integration plugin fixes (#230) Thanks @deepmroot. Changed: - iii-engine pinned to v0.11.2 across every install path (#260). v0.11.6 introduces a new `iii worker add` sandbox model that agentmemory still pre-dates; pin lifts when we refactor agentmemory to register as a sandboxed worker. Override with AGENTMEMORY_III_VERSION=<version> for users who've migrated manually. - README documents iii worker add extension surface (#242). - README iii Console install/launch commands corrected (#243). Validated: 852/852 tests pass, npm run build clean.
Summary
Validated locally
/agentmemory/healthSummary by CodeRabbit
Documentation
New Features
Updates