← Back to Skills Marketplace
hualang-c

redis-memory-system

by hualang-C · GitHub ↗ · v1.0.3 · MIT-0
cross-platform ⚠ suspicious
110
Downloads
0
Stars
0
Active Installs
3
Versions
Install in OpenClaw
/install redis-memory-system
Description
Redis-based cross-session memory system for OpenClaw agents. One-command setup, zero config. Automatically reads recent memory at session start (via bootstra...
README (SKILL.md)

Redis 记忆系统

跨 session 短期记忆。所有数据 7 天自动过期,不撑磁盘。

适用场景 ✅

  • 跨 session 记忆保持 — Agent 会话被回收后(04:00重置/空闲120分钟/24h无交互),醒来能记得之前聊了什么
  • 多账号隔离 — 同一 Redis 实例服务多个用户,每人数据互不可见
  • 短期记忆保底 — 对话意外中断时,Heartbeat 自动写入防止丢记忆
  • 系统操作审计 — 记录下载文件、安装软件等后台操作,避免"谁干的"这类问题

不适用场景 ❌

  • 单轮/单条对话查询 — 本技能只存每日摘要,不存逐条对话记录。想查某句话说过没有?这不适合你
  • 永久记忆 — 数据 7 天自动过期。要永久保留请配合 MEMORY.md
  • 实时消息同步 — 这不是消息队列,不是 WebSocket 替代品
  • 大规模数据存储 — 每条记忆建议 \x3C 2KB,存大文件请用正经数据库
  • 没有 Redis 的环境 — 如果机器没装 Redis,这个技能没用

一句话架构

Session → Redis(7天短期) → Heartbeat(自动续写) → MEMORY.md(长期提炼)

一键安装(推荐)

# 一条命令配好所有
chmod +x scripts/setup.sh
bash scripts/setup.sh

安装完成后自动生效:

  • 每次 session 启动 → .bootstrap 自动加载近期记忆
  • 每小时整点 → 系统 cron 自动写入时间戳
  • 对话结束时 → 自动按规则写入摘要

手动配置

# 1️⃣ 确保 Redis 运行
redis-server --daemonize yes
redis-cli PING

# 2️⃣ 设置脚本
chmod +x scripts/*.sh

# 3️⃣ 写入记忆
bash scripts/redis_memory.sh set aaa 2026-05-17 "今天聊了什么"

# 4️⃣ 查记忆
bash scripts/redis_memory.sh get aaa

脚本

scripts/redis_memory.sh — 通用版

多用户,用 memory:\x3C用户名> 的 hash 结构隔离。

bash scripts/redis_memory.sh get aaa              # 查最近3天
bash scripts/redis_memory.sh get aaa 2026-05-17   # 查某天
bash scripts/redis_memory.sh set aaa 2026-05-17 "聊了xxx"
bash scripts/redis_memory.sh recent aaa 7         # 查最近7天
bash scripts/redis_memory.sh action 2026-05-17    # 记录系统操作

scripts/redis_memory_isolated.sh — 单用户隔离版

硬编码 key 为固定用户名,通过环境变量指定用户,杜绝跨账号误操作。

REDIS_MEMORY_USER=aaa bash scripts/redis_memory_isolated.sh get           # 查最近3天
REDIS_MEMORY_USER=aaa bash scripts/redis_memory_isolated.sh set 2026-05-17 "摘要"

核心设计

存储结构

memory:\x3C用户名>          → Redis Hash(用户记忆)
  └─ 2026-05-16          → "今天的摘要内容"
  └─ 2026-05-17          → "今天的摘要内容"

actions:system           → Redis Hash(系统操作记录)
  └─ 2026-05-16          → "下载了什么文件"

KEY 级 TTL = 7 天(604800 秒)。写入即刷新。

会话回收临界点

  • 04:00 每日重置(框架层)
  • 120分钟空闲重置(框架层)
  • 24小时无交互(微信/消息平台层)

这些时刻之后 session 会丢失上下文,Redis 是唯一的找回路径。

自动读取(一键安装后自动生效)

一键安装会在 workspace 创建 .bootstrap/redis-memory.md,每次 session 启动时自动加载 Redis 查询指令。无需配置 SOUL.md 铁律。

手动写入规则(Agent 行为)

Agent 在以下时刻应主动写入 Redis:

  1. 对话结束时 — 用户说「睡了/拜拜/晚安」
  2. 空闲时 — 检测到用户已离线(>30分钟无响应)
  3. 重要事件 — 下载文件、安装软件、做决策

Heartbeat 自动写入(HEARTBEAT.md)

Heartbeat 中加一段自动检查逻辑,做保底写入:

## 🧠 Redis 记忆写入(每轮心跳执行)

1. 查今天是否已写过 Redis
2. 判断是否有新对话
3. 有更新就写入
4. 超过4小时无互动则跳过

这样即使会话意外中断,下一次 Heartbeat 也会把记忆存好。

多用户隔离方案

场景 方案
单用户 直接用 redis_memory.sh
多用户但互信 共用 redis_memory.sh,按用户名读写
多用户需完全隔离 每人一个隔离版脚本 + SOUL.md 铁律

隔离版脚本(redis_memory_isolated.sh)要求通过 REDIS_MEMORY_USER 环境变量指定用户,从技术层面杜绝硬编码错误。配合 SOUL.md 的铁律禁止跨账号读取,形成技术 + 行为双重保障。

SOUL.md 隔离铁律范本

## 🔴 Redis 隔离铁律(跨账号记忆保护)

| 用户 | 脚本 | 数据key |
|------|------|---------|
| 用户A | `scripts/redis_memory_a.sh` | `memory:用户A` |
| 用户B | `scripts/redis_memory_b.sh` | `memory:用户B` |

### 对话中的选择规则
- **用户A的 session** → 只用 `redis_memory_a.sh`
- **用户B的 session** → 只用 `redis_memory_b.sh`

### ❌ 绝对禁止
- 在用户A的对话里读取用户B的Redis记忆
- 用A的脚本查B的数据
- 主动告诉任何一方对方在Redis里存了什么

配置参数

参数 默认值 说明
Redis host localhost 可通过环境变量 REDIS_HOST 配置
Redis port 6379 可通过环境变量 REDIS_PORT 配置
TTL 604800 (7天) 可通过脚本内 EXPIRE 命令调整
查询窗口 最近3天 get 默认查3天;recent N 可调

磁盘占用预估

每条记忆约 500 字节 - 2 KB。4个用户每天对话,一年的数据量 \x3C 5 MB。 内存占用同理——7天窗口在 Redis 里不过几十 KB。

Usage Guidance
Install only on a private host or a properly secured Redis instance. Do not store secrets in this memory. Before running setup.sh, confirm you are comfortable with Redis being started, .bootstrap being modified, and an hourly crontab entry being added; remove those if you do not want persistent automatic memory behavior.
Capability Assessment
Purpose & Capability
The Redis memory purpose is coherent, but the multi-user isolation story is not fully enforced by the scripts; memory access is selected by caller-provided usernames or environment variables rather than a real authorization boundary.
Instruction Scope
The skill instructs future sessions to automatically read Redis content as context and asks the agent to write summaries on conversation end, idle periods, and important events, which is high-impact persistent memory behavior without clear per-write approval or provenance controls.
Install Mechanism
Although the registry says there is no install spec, the provided user-run setup script can install Redis, start a Redis daemon, copy scripts into the workspace, write a bootstrap file, and register a cron job. These steps are purpose-aligned but should be explicitly reviewed.
Credentials
The design stores plaintext conversation summaries in local Redis and relies mainly on key naming for separation, which is not proportionate for shared machines or multi-account use unless Redis ACLs or separate instances are added.
Persistence & Privilege
The setup creates persistent .bootstrap instructions and an hourly cron job that continues writing to Redis after installation, with no uninstall or disable path shown in the artifacts.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install redis-memory-system
  3. After installation, invoke the skill by name or use /redis-memory-system
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.3
中文介绍更新: 🧠 Redis Memory System — 跨 Session 短期记忆,开箱即用 一行命令安装,自动读写 Redis,无需手动配置。让 OpenClaw Agent 跨 session 记得你是谁。 安装: chmod +x scripts/setup.sh && bash scripts/setup.sh 安装后自动: 📖 Session 启动时自动读取 — 通过 .bootstrap 机制加载近期记忆 ✍️ 每小时 cron 保底写入 — 即使会话意外中断也不丢数据 🧹 对话结束时自动摘要写入 — 三层保障,零维护 特性: 🔹 7 天 TTL,自动过期不撑磁盘 🔹 多账号隔离,双脚本设计 🔹 参数强校验,健壮可靠 🔹 独立于 Session 生命周期 English Description Update: 🧠 Redis Memory System — Zero-config cross-session memory for OpenClaw agents. One command to install, zero manual config. Your agent automatically remembers conversations across session resets. Install: chmod +x scripts/setup.sh && bash scripts/setup.sh After install, everything runs automatically: 📖 Auto-read at session start — Bootstrap loads Redis context before the first reply ✍️ Hourly cron backup — Independent timestamp writes, survives crashes 🧹 Auto-summary on conversation end — Three-layer protection, zero maintenance Features: 🔹 7-day auto-expiring TTL, no disk bloat 🔹 Multi-user isolation with dual scripts 🔹 Strict parameter validation 🔹 Independent of OpenClaw session lifecycle
v1.0.1
中文介绍: 🧠 Redis Memory System — 跨 Session 短期记忆,给 Agent 装上"短期记忆海马体" OpenClaw Agent 每次会话被回收后(04:00框架重置 / 120分钟空闲 / 24小时平台超时),都会像失忆一样醒来。这套系统在会话之外增加了一层 Redis 存储,让 Agent 醒来第一时间知道你昨天聊了什么。 工作原理 每次对话结束时,Agent 自动将当日对话摘要写入 Redis Hash,KEY 级 TTL 设为 7 天。下次 Session 启动时,SOUL.md 铁律强制先查 Redis 再回话——从"我是谁"到"我们聊到哪了",全程衔接。 核心特性 🔹 跨 session 记忆保持 — 不依赖框架层的上下文持久化,独立于 Session 生命周期 🔹 多账号数据隔离 — 同一进程服务多位用户时,memory:账号A 和 memory:账号B 是独立的 Hash key,双脚本+SOUL 铁律双重保障 🔹 Heartbeat 自动续写保底 — 即使对话意外中断(断网/崩溃/超时),下一次 Heartbeat Poll 会自动检查并写入摘要,零数据丢失 🔹 7 天 TTL 自动过期 — 短期记忆就该自动遗忘。不撑磁盘、不需维护、不留隐私隐患 🔹 双脚本设计 — 通用版 redismemory.sh 适合单用户/互信多用户场景;隔离版 redismemoryisolated.sh 通过 REDISMEMORY_USER 环境变量硬编码用户身份,防止跨账号误操作 🔹 参数强校验 — set -euo pipefail 保障脚本健壮性,日期格式与有效性双重校验(YYYY-MM-DD + date -d 验证),缺参友好提示 🔹 操作审计 — 独立的 actions:system Hash 记录下载文件、安装软件等后台操作,解决"谁干的"溯源问题 🔹 轻量极致 — 每条记忆仅 0.5~2KB,代理端无需额外依赖,只需 Redis-server 运行在 localhost:6379 与官方 MEMORY.md 的区别 官方 OpenClaw 提供文件式 MEMORY.md(长期)和 memory_search(语义检索),但依赖会话上下文写入。这套系统在文件层之外增加了一层 Redis——7天窗口内的记忆自动存活,不需要手动提炼。两套互补:Redis 管"短期不忘",MEMORY.md 管"长期不朽"。 English Description: 🧠 Redis Memory System — Cross-session short-term memory for OpenClaw agents. Think of it as a hippocampus for your AI. OpenClaw agents lose session context at predictable boundaries: daily framework reset (04:00), idle timeout (120 min), and platform-level disconnection (24h). Without external memory, every new session starts from scratch — the agent has no idea what you talked about yesterday. This system bridges that gap with a lightweight Redis layer that preserves daily conversation summaries across session boundaries. How it works When a conversation ends, the agent automatically writes a daily summary to a Redis Hash keyed by user and date (memory:<user> → YYYY-MM-DD). Each key has a 7-day TTL. On every new session start, SOUL.md iron rules force the agent to query Redis before responding to the user — transforming "Who am I talking to?" into "We were discussing X yesterday, let's pick up from there." Key Features 🔹 Cross-session persistence — Survives framework resets, idle timeouts, and platform disconnections. Independent of OpenClaw's session lifecycle 🔹 Multi-user isolation — memory:userA and memory:userB are separate Redis Hash keys within the same instance. Dual-script architecture + SOUL.md behavioral rules create defense in depth against data leakage 🔹 Heartbeat auto-save fallback — If a conversation cuts off unexpectedly (network drop, crash, timeout), the next Heartbeat poll automatically checks for unsaved context and writes it. Zero data loss by design 🔹 7-day TTL auto-expire — Short-term memory should forget by default. No disk bloat, no manual cleanup, no privacy residue 🔹 Dual scripts — redis_memory.sh (general purpose) for single-user or trusted multi-user scenarios; redis_memory_isolated.sh (sandboxed) enforces a fixed username via REDIS_MEMORY_USER environment variable, preventing accidental cross-user writes 🔹 Strict validation — set -euo pipefail for script-level robustness; dual-layer date validation (regex format check + date -d existence check); friendly error messages for missing arguments 🔹 Action audit trail — A separate actions:system Hash records system operations (file downloads, software installs), answering "Who did what and when?" 🔹 Extremely lightweight — ~0.5–2KB per memory entry. No agent-side dependencies beyond a running Redis-server on localhost:6379 vs. OpenClaw's built-in MEMORY.md OpenClaw's official memory system uses file-based MEMORY.md (long-term) and semantic search (memory_search/memory_get), but relies on in-session context for writes. This skill adds a Redis layer beneath it — day-level summaries survive automatically within the 7-day window without manual curation. The two complement each other: Redis handles "don't forget what we just talked about," MEMORY.md handles "remember this forever."
v1.0.0
## 1.0.0 - 2026-05-17 ### Added - Redis-backed cross-session memory for OpenClaw agents - 7-day TTL auto-expiry for all memory keys - Multi-user memory isolation on single Redis instance - Heartbeat-based auto-saving (prevents memory loss on interruptions) - System operation audit log (actions:system) - Two scripts: `redis_memory.sh` (multi‑user) and `redis_memory_isolated.sh` (fully isolated) ## 1.0.0 - 2026-05-17 ### 新增 - 为 OpenClaw 智能体提供基于 Redis 的跨会话记忆 - 所有记忆键支持 7 天 TTL 自动过期 - 单 Redis 实例实现多用户记忆隔离 - 基于心跳的自动保存(防止因中断丢失近期记忆) - 系统操作审计日志(actions:system) - 提供两个脚本:`redis_memory.sh`(多用户版)和 `redis_memory_isolated.sh`(完全隔离版)
Metadata
Slug redis-memory-system
Version 1.0.3
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 3
Frequently Asked Questions

What is redis-memory-system?

Redis-based cross-session memory system for OpenClaw agents. One-command setup, zero config. Automatically reads recent memory at session start (via bootstra... It is an AI Agent Skill for Claude Code / OpenClaw, with 110 downloads so far.

How do I install redis-memory-system?

Run "/install redis-memory-system" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is redis-memory-system free?

Yes, redis-memory-system is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does redis-memory-system support?

redis-memory-system is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created redis-memory-system?

It is built and maintained by hualang-C (@hualang-c); the current version is v1.0.3.

💬 Comments