AgentMemory Adapter
Use this skill to make AgentMemory a dependable shared memory layer, not just a copied MCP snippet.
When To Use
Use this skill when the user wants to install AgentMemory, wire AgentMemory MCP into Codex or OpenClaw, audit an existing memory setup, publish AgentMemory guidance to ClawHub, or debug memory failures involving npx, localhost routing, bearer-token safety, stale hooks, duplicate plugin paths, or degraded MCP fallback mode.
Operating Order
- Confirm the target surface: Codex, OpenClaw, ClawHub skill packaging, or a specific project workspace.
- Read the bundled references for current architecture and platform-specific recipes.
- Prefer a pinned local AgentMemory binary over long-lived
npxcommands. - Apply the narrowest config change that satisfies the target surface, preserving existing user settings.
- Run the diagnostic script before and after changes, then explain any warnings as operational risks rather than hiding them.
- For public skill work, run Codex quick validation, ClawHub skill doctor, leak/prompt-bleed scans, ClawPatch review, and a gstack-style ship gate before publishing.
First Pass
- Inspect the target agent and project scope before editing config. Prefer user-level integration for "all current projects"; prefer repo-local integration only when the user asks for project-specific behavior.
- Read
references/agentmemory-deep-analysis.mdfor the current AgentMemory architecture andreferences/platform-recipes.mdfor exact Codex, OpenClaw, and ClawHub-ready patterns. - Run
scripts/check_agentmemory.pybefore and after changes. Use--url <base-url>when the server is remote or uses a non-default port. - Preserve existing user config and backups.
agentmemory connectwrites backups under~/.agentmemory/backups; manual JSON/TOML edits should be equally scoped.
Install Strategy
Prefer a stable local command over unbounded npx in long-lived MCP configs:
npm install --prefix ~/.agentmemory/npm @agentmemory/agentmemory@0.9.22 --omit=optional
mkdir -p ~/.local/bin
ln -sfn ~/.agentmemory/npm/node_modules/.bin/agentmemory ~/.local/bin/agentmemory
Use full optional dependencies only when the user explicitly needs local vector/image embeddings and accepts native package install cost. If npx @agentmemory/agentmemory@latest stalls, install the core package locally as above and point MCP entries at ~/.local/bin/agentmemory mcp.
Codex Workflow
- Wire MCP with the local command:
codex mcp remove agentmemory 2>/dev/null || true
codex mcp add agentmemory \
--env AGENTMEMORY_URL=http://localhost:3111 \
--env AGENTMEMORY_TOOLS=all \
-- ~/.local/bin/agentmemory mcp
- Install the Codex hook fallback when Codex Desktop or plugin-local hooks are unreliable:
agentmemory connect codex --with-hooks --force
Then re-run the MCP add command above if connect rewrites the server back to npx.
-
Install the upstream Codex plugin or a local marketplace copy when slash skills are wanted. Patch the plugin
.mcp.jsonto the local command if avoidingnpx. -
Verify:
codex mcp list
python3 ~/.codex/skills/agentmemory-adapter/scripts/check_agentmemory.py
OpenClaw Workflow
- Add the MCP server:
openclaw mcp set agentmemory '{"command":"'"$HOME"'/.local/bin/agentmemory","args":["mcp"],"env":{"AGENTMEMORY_URL":"http://localhost:3111","AGENTMEMORY_TOOLS":"all"}}'
- Install or link the OpenClaw memory plugin from a durable directory, not a temporary source checkout.
- Ensure
plugins.slots.memoryisagentmemory,plugins.entries.agentmemory.enabledis true, and the plugin config includesbase_url,token_budget,min_confidence,fallback_on_error, andtimeout_ms. - Verify with:
openclaw mcp show agentmemory
openclaw plugins inspect agentmemory
openclaw plugins doctor
Edge-Case Rules
- Treat MCP fallback mode as degraded: it exposes only a small local tool set when the REST server is unreachable. Start the server for the full tool surface.
- For sandboxed agents,
localhostmay point inside the sandbox. Use a reachable host route andAGENTMEMORY_FORCE_PROXY=1only when the route is correct. - Never send
AGENTMEMORY_SECRETover non-loopbackhttp://. Prefer HTTPS or SSH tunneling; setAGENTMEMORY_REQUIRE_HTTPS=1for hard failure. - Re-run
agentmemory connect codex --with-hooksafter upgrading AgentMemory because user-scope hooks contain absolute script paths. - Remove duplicate OpenClaw plugin paths; stale temp paths can shadow durable installs.
- Use
AGENT_IDandAGENTMEMORY_AGENT_SCOPE=isolatedonly when roles need strict separation. Default shared memory is usually better for one user's coding agents. - Keep
AGENTMEMORY_INJECT_CONTEXT=falseandAGENTMEMORY_AUTO_COMPRESS=falseunless the user explicitly accepts token spend. - Do not use
memory_governance_deleteor the/forgetworkflow without explicit confirmation.
ClawHub-Ready Skill Work
For a skill intended for ClawHub, keep SKILL.md concise, declare OpenClaw runtime requirements in metadata.openclaw, avoid paid-skill/licensing claims, and include a --clawscan-note when publishing because this workflow intentionally configures local binaries, MCP, and network access. Use references/platform-recipes.md before publishing or reviewing the bundle.
微信扫一扫