Skip to main content

agentmemory Backend

OpenHuman uses sqlite as the default backend for the Memory trait. For users who already self-host agentmemory, OpenHuman provides an optional backend that proxies all trait calls via agentmemory's REST interface.

Selecting backend = "agentmemory" completely bypasses OpenHuman's SQLite + Embedder path. agentmemory handles storage, embedding, and retrieval; OpenHuman becomes a lightweight REST client.

Use Cases

When to use agentmemory backend:

  • You're already running npx -y @agentmemory/agentmemory for Claude Code, Cursor, Codex, OpenCode, or OpenHuman and want to share the same persistent storage
  • You want hybrid BM25 + vector + graph retrieval without configuring a separate Embedder on the OpenHuman side
  • You prefer agentmemory's lifecycle (merging, retention scoring, automatic forgetting, graph extraction) over OpenHuman's unified storage

When to keep the default SQLite backend:

  • You want fully self-contained single-process operation without relying on an external daemon
  • You depend on OpenHuman-specific memory tree features (chunking, sealing, summary trees running on top of SQLite storage)

Quick Start

  1. Install and start agentmemory (in one terminal):
npx -y @agentmemory/agentmemory

Runs on http://localhost:3111 (REST) and ws://localhost:49134 (engine) by default. First launch generates an HMAC key in ~/.agentmemory/.hmac and prints it once.

  1. Configure OpenHuman in config.toml to point to it:
[memory]
backend = "agentmemory"
#下面的默认值 - 只有需要覆盖时才设置
# agentmemory_url = "http://localhost:3111"
# agentmemory_secret = "" # HMAC bearer token, optional
# agentmemory_timeout_ms = 5000
  1. Restart OpenHuman. Factory skips SQLite path and logs [memory::factory] using agentmemory backend at <url>.

Configuration Fields

FieldDefaultPurpose
agentmemory_urlhttp://localhost:3111Base URL for agentmemory REST server
agentmemory_secretnoneOptional HMAC bearer token
agentmemory_timeout_ms5000Per-request reqwest timeout

When backend == "agentmemory", the following existing MemoryConfig fields are ignored — agentmemory manages its own embedding stack via ~/.agentmemory/.env:

  • embedding_provider
  • embedding_model
  • embedding_dimensions
  • sqlite_open_timeout_secs

Field Mapping

OpenHuman's MemoryEntry ↔ agentmemory row data:

OpenHuman Fieldagentmemory FieldDescription
namespaceprojectDefaults to "default" when empty
keytitle
contentcontent
ididagentmemory-generated (mem_<rand>)
category: Coretype: "fact"
category: Dailytype: "conversation"
category: Conversationtype: "conversation"
category: Custom(s)type: "fact" + concepts: [s]Custom tags merged into concepts array
session_idsessionIds: [...]OpenHuman exposes single id; agentmemory persists an array
timestampupdatedAt (RFC3339)Falls back to createdAt if updatedAt doesn't exist

RPC Method Mapping

Memory Methodagentmemory RESTDescription
storePOST /agentmemory/remember
recallPOST /agentmemory/smart-searchHybrid BM25 + vector + graph
getPOST /agentmemory/smart-search+ client-side exact title filter
listGET /agentmemory/memories?latest=true&project=<ns>
forgetget(ns, key)POST /agentmemory/forgetTwo steps: resolve id then forget
namespace_summariesGET /agentmemory/projects
countGET /agentmemory/health
health_checkGET /agentmemory/livez

Security

When agentmemory_secret is set, the client follows agentmemory's v0.9.12 plaintext bearer protection convention:

  • Loopback hosts (localhost, 127.0.0.1, ::1) via http:// — allowed
  • https:// to any host — allowed
  • Plaintext HTTP to non-loopback hosts — one-time stderr warning at construction
  • AGENTMEMORY_REQUIRE_HTTPS=1 — upgrades warning to hard rejection

Production deployments should set AGENTMEMORY_REQUIRE_HTTPS=1 so a misconfigured TLS terminator fails loudly rather than silently leaking.

Failure Modes

FailureBackend Behavior
Daemon unreachable at startupfrom_config succeeds (URL parsing), but health_check() returns false
Network timeoutReturns anyhow::Error per trait contract
4xx / 5xx responseanyhow::Error with status and body snippet
Plaintext bearer to non-loopbackOne-time warning, request proceeds
Plaintext bearer + AGENTMEMORY_REQUIRE_HTTPS=1Hard rejection at construction

No automatic fallback to SQLite. If the daemon is down at startup, the backend exposes transport errors loudly.

Next Steps