AI Memory
Motorhead — Lightweight Redis-Backed Chat Memory Server logo

Motorhead — 基于 Redis 的轻量聊天记忆服务

Motorhead 是一个用 Rust 实现的开源记忆服务,基于 Redis 存储对话历史并维护滚动摘要,提供极简 REST API。为 LLM 应用增加"最近 N 轮 + 摘要"记忆的最简方案。

为什么选它

Motorhead is the "just enough memory" option. It doesn’t extract facts, doesn’t build a graph, doesn’t support multi-user fact scoping. What it does: store messages per session in Redis, keep a running summary so the history doesn’t explode, and expose a REST API with two endpoints. That’s it.

The project was originally built by Metal (a RAG startup) and still sees maintenance for bug fixes but no major new features. Use it when you need chat memory today, don’t want to operate Postgres, and find Zep or mem0 heavier than the problem calls for.

The cost of simplicity: no cross-session memory. A user’s history from yesterday doesn’t influence today’s conversation unless you manually link sessions. For single-session chatbots this is fine; for assistants that accumulate user knowledge, you’ll outgrow Motorhead.

Quick Start — Docker Compose + HTTP

Motorhead runs summarization automatically once a session exceeds a configurable token budget. You always get back (a) the most recent messages verbatim and (b) a summary string covering everything older. Feed both into your LLM prompt.

# docker-compose.yml
# services:
#   redis: { image: redis/redis-stack:latest, ports: ["6379:6379"] }
#   motorhead:
#     image: ghcr.io/getmetal/motorhead:latest
#     ports: ["8080:8080"]
#     environment:
#       OPENAI_API_KEY: sk-...
#       REDIS_URL: redis://redis:6379
#     depends_on: [redis]

# Start the stack
docker compose up -d

# Append messages to a session
curl -X POST http://localhost:8080/sessions/s1/memory \
  -H "content-type: application/json" \
  -d '{"messages":[
    {"role":"user","content":"I want a vegan dinner recipe"},
    {"role":"assistant","content":"How about a chickpea curry?"}
  ]}'

# Fetch memory for the next LLM call
curl http://localhost:8080/sessions/s1/memory
# => { "messages": [...last N turns...], "context": "<running summary>" }

核心能力

Redis-only storage

No Postgres, no vector DB dependency. Scale Redis horizontally; Motorhead scales trivially behind a load balancer.

Rolling summarization

When a session crosses ~1K tokens, Motorhead asks an LLM to summarize the older turns and keeps the summary + recent messages. Configurable window.

Tiny REST API

Two endpoints: POST messages, GET memory. No SDK required — works from any language with an HTTP client.

Language-agnostic

Because the API is just HTTP, you use it the same from Python, Node, Go, Rust, Elixir. Trivial to wire into existing chat backends.

Open source

Apache 2.0 licensed; self-host anywhere Docker runs. No managed offering (use Upstash or your cloud’s managed Redis for infra).

Low operational overhead

Single Rust binary + Redis. No background workers, no schema migrations. Runs comfortably on a small VM for many thousands of concurrent sessions.

对比

 ScopeStorageCross-session memoryOperational complexity
MotorheadthisPer-session onlyRedisNoVery low
ZepPer-session + per-user factsPostgres + pgvectorYesMedium
mem0Per-user factsVector DB of choiceYesLow-medium
LangMemPer-thread (LangChain)LangChain-backedOpt-inLow

实际用例

01. Single-session chatbots

Customer support widgets, onboarding bots, or helpdesk assistants where each conversation is independent. Motorhead gives you "remember the last 30 minutes" cheaply.

02. Prototypes and MVPs

When you want working memory in an afternoon without standing up Postgres and a migration story. Trade up to Zep or mem0 once the prototype validates.

03. Edge or privacy-sensitive deployments

Redis + Motorhead runs on a single small VM, on-prem, or on a customer’s infrastructure. No vector DB dependency keeps the threat surface small.

价格与许可

Motorhead: Apache 2.0 open source, self-host only. No managed offering.

Infra cost: one Redis instance (managed Redis from Upstash/AWS/Redis Cloud costs as little as $10/month) + one tiny VM for Motorhead itself. Summarization LLM calls use your own OpenAI/Claude key.

Scale limits: single Redis instance handles hundreds of thousands of sessions for typical chat traffic. Past that, shard by session_id — standard Redis scaling patterns apply.

常见问题

Motorhead vs Zep — which should I use?+

Motorhead when sessions are independent and you want the smallest possible stack. Zep when you need user-level memory, hybrid search, or the web UI. Zep is a superset of what Motorhead does.

Does Motorhead support multiple users?+

Indirectly — you can use session_id = "${user_id}:${thread_id}". There’s no first-class user concept, so cross-session user facts need another layer on top.

Can I run it without OpenAI?+

Yes. Point SUMMARIZER_API_BASE at any OpenAI-compatible endpoint (Ollama, vLLM, LM Studio, LiteLLM). Summarization is the only LLM work Motorhead does, and it’s configurable.

Is Motorhead still maintained?+

It receives occasional bug fixes but is effectively feature-frozen. The team’s focus has shifted. For new projects consider Zep or mem0, but Motorhead remains a solid small-stack choice if you value its minimalism.

How do I migrate off Motorhead later?+

Because data is just Redis keys ({session_id}:messages and {session_id}:context), export is straightforward: SCAN + GET. Import into Zep or mem0 by replaying the messages through their respective ingestion APIs.

同类推荐