Skip to content

feat(memory): add memory-graphiti extension with dual-backend support - #4

Closed
supmo668 wants to merge 1 commit into
mainfrom
feat/graphiti
Closed

supmo668 wants to merge 1 commit into
mainfrom
feat/graphiti

Conversation

@supmo668

Copy link
Copy Markdown

Summary

  • Problem: OpenClaw lacks a graph-based knowledge memory plugin that can extract entities, relationships, and temporal facts from conversations.
  • Why it matters: Graph memory enables agents to build persistent, structured knowledge that improves over time — capturing not just facts but how they relate and when they change.
  • What changed: New memory-graphiti extension in extensions/memory-graphiti/ with dual-backend support (Zep Cloud managed service + self-hosted Graphiti REST API), auto-capture/recall hooks, search tools, and CLI.
  • What did NOT change (scope boundary): No changes to core memory interfaces, existing memory-lancedb plugin, or any other plugins.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • New memory-graphiti plugin available in the memory slot
  • Configurable via apiKey (Zep Cloud) or serverUrl (self-hosted Graphiti)
  • Auto-capture: conversations are automatically sent to the knowledge graph after each agent turn
  • Auto-recall: relevant facts are injected as context before each agent turn
  • Two new agent tools: graphiti_search (search knowledge graph) and graphiti_episodes (retrieve recent episodes)
  • New CLI command: openclaw graphiti status to check connectivity
  • Group ID strategies: channel-sender (default, per-user per-channel), session (per-thread), static (shared graph)

Security Impact (required)

  • New permissions/capabilities? Yes — new memory plugin with network access to Zep Cloud or self-hosted Graphiti
  • Secrets/tokens handling changed? Yes — apiKey field marked sensitive: true, supports ${ENV_VAR} resolution
  • New/changed network calls? Yes — calls to Zep Cloud API (api.getzep.com) or self-hosted Graphiti REST API
  • Command/tool execution surface changed? Yes — two new agent tools (graphiti_search, graphiti_episodes)
  • Data access scope changed? No — operates within the memory plugin slot, same as existing memory plugins
  • Risk + mitigation: API key stored in config with sensitive: true flag. Environment variable resolution prevents hardcoded secrets. All network calls go to user-configured endpoints only.

Repro + Verification

Environment

  • OS: Linux (WSL2)
  • Runtime/container: Node.js (pnpm workspace)
  • Model/provider: N/A (plugin infrastructure)
  • Integration/channel: Zep Cloud + self-hosted Graphiti
  • Relevant config (redacted): { "apiKey": "${GETZEP_API_KEY}" }

Steps

  1. Configure plugin with Zep Cloud API key or self-hosted Graphiti URL
  2. Send messages through an agent
  3. Verify facts are captured and recalled

Expected

  • Messages captured into knowledge graph
  • Relevant facts injected before agent turns
  • Search tools return graph entities/edges

Actual

  • Verified via 49 unit tests and 6 Zep Cloud integration tests

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

49 unit tests covering: config parsing (15), client factory (3), group ID derivation (9), message extraction (7), fact formatting (3), REST client (12).
6 integration tests against live Zep Cloud: healthcheck, addMessages, getEpisodes (with polling), searchFacts.

Human Verification (required)

  • Verified scenarios: Unit tests pass, integration tests pass against live Zep Cloud API
  • Edge cases checked: Config validation (missing keys, invalid strategies, env var resolution), dual-backend auto-detection, user creation idempotency (400 + 409 handling), empty message arrays, content block extraction
  • What you did not verify: Self-hosted Graphiti backend (Railway deployment has missing OPENAI_API_KEY for entity extraction)

Compatibility / Migration

  • Backward compatible? Yes — new extension, no changes to existing code
  • Config/env changes? Yes — new GETZEP_API_KEY or GRAPHITI_SERVER_URL env vars needed
  • Migration needed? No

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Remove memory-graphiti from plugin slot config, or uninstall extension
  • Files/config to restore: Only extensions/memory-graphiti/ directory — fully self-contained
  • Known bad symptoms reviewers should watch for: Network timeouts to Zep Cloud, missing API key errors

Risks and Mitigations

  • Risk: Zep Cloud SDK API changes could break cloud client
    • Mitigation: SDK version pinned to ^3.16.0, integration tests validate live API
  • Risk: Self-hosted Graphiti REST API schema drift
    • Mitigation: REST client uses minimal endpoint surface; typed response interfaces

@supmo668

Copy link
Copy Markdown
Author

@greptileai review

Graph-based knowledge memory plugin using Graphiti for temporally-aware
knowledge graphs. Supports two backends:

- Zep Cloud (managed) via @getzep/zep-cloud SDK
- Self-hosted Graphiti via REST API

Features: auto-capture (agent_end), auto-recall (before_agent_start),
graphiti_search/graphiti_episodes tools, CLI status command, and
configurable group ID strategies (channel-sender, session, static).

Includes 49 unit tests and 6 integration tests against Zep Cloud.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@github-actions

Copy link
Copy Markdown

⚠️ Formal models conformance drift detected

The formal models extracted constants (generated/*) do not match this openclaw PR.

This check is informational (not blocking merges yet).
See the formal-models-conformance-drift artifact for the diff.

If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there.

@supmo668

Copy link
Copy Markdown
Author

PR Review Summary — feat/graphiti

Critical Issues (2 found)

# Issue Location
1 Mutable lastGroupId shared across concurrent sessions — race condition & data leak. agent_end mutates a closure variable read by before_agent_start and tool handlers. In a multi-session gateway, user A's group ID leaks into user B's context. index.ts:258,415,450
2 Silent fallback on invalid groupIdStrategy — user gets "channel-sender" silently instead of a config error. config.ts:480-484

Important Issues (6 found)

# Issue Location
3 Repeated as Record<string, unknown> casts in extractMessages — use a type guard index.ts:193,217-221
4 Bare console.log in CLI command — should use palette/logger per guidelines index.ts:396
5 Inconsistent optional chaining on api.logger.info?.() vs api.logger.info() index.ts (various)
6 No tsconfig.json in extension dir — verify compilation scope Extension root
7 Duplicate uiHints in both config.ts and openclaw.plugin.json — maintenance burden config.ts:512-552, openclaw.plugin.json:4-49
8 Integration tests use fixed setTimeout waits (10s) — flaky in CI integration.test.ts:1558,1568

Suggestions (4 found)

# Suggestion Location
9 Add provider field to GroupIdContext type config.ts:363
10 Use named regex captures in extractSenderFromSessionKey config.ts:409-416
11 Pin @getzep/zep-cloud to exact version given SDK stability risk package.json:8
12 Rename escapeForPrompt → escapeXml for clarity index.ts:157-167

Strengths

  • Clean dual-backend MemoryClient interface abstraction
  • 49 unit tests with good edge case coverage
  • Prompt injection protection (XML wrapper + escape)
  • Proper plugin structure (extensions/* conventions, deps in extension package.json)
  • Fire-and-forget capture with error handling
  • Idempotent user creation (handles 400/409)
  • AbortSignal.timeout on all REST calls

Verdict: NEEDS FIXES — Critical #1 (race condition / data leak) must be fixed before merge.

🤖 Generated with Claude Code

supmo668 added a commit that referenced this pull request Jun 21, 2026
…QGR 509f0a5

fix(syntropy): user-facing onboarding strings — Link→Pair Device, brand (oc-hygiene #4)
@supmo668

supmo668 commented Oct 2, 2026

Copy link
Copy Markdown
Author

Superseded: closing (cto-loop W26 hygiene, CTO openclaw#13303).

memory-graphiti shipped on main via #9 (655cdc5, 2026-05-12) and was extended after that (P1 characterization tests 37d6b07; tripwire; the register now in openclaw.json). main has 17 files under extensions/memory-graphiti. This branch (0fa0f4f, 2026-02-25) is an older subset: merging it would DELETE ~2.9k lines from main (git diff origin/main origin/feat/graphiti -- extensions/memory-graphiti: +175/-2881). Nothing on this branch is missing from main.

@supmo668 supmo668 closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant