AI Agent Memory Safety System - Give your AI agent a "time machine" for safe evolution
这是一个专门为AI agent设计的版本控制系统,解决了记忆污染和不安全进化的关键问题。
AI agent持续学习和进化:
学习 → 记忆 → 进化 → 继续学习...
但如果:
- ❌ AI学习了错误信息?
- ❌ 记忆被污染?
- ❌ 安装了不安全的skill?
- ❌ 配置出错?
- ❌ 无法回退!
本系统为AI agent提供**"时间机器"**:
学习 → 记忆 → 版本保存 → 发现问题 → 回退 → 继续学习...
核心功能:
- ✅ 记忆安全:回退被污染的记忆
- ✅ Skill安全:撤销不安全的skill
- ✅ 配置安全:恢复错误的配置
- ✅ 安全实验:使用分支测试
- ✅ 历史追溯:追踪所有变更
# 克隆仓库
git clone https://github.com/ExuberantWitness/openclaw-workspace-version-control.git
cd openclaw-workspace-version-control
# 运行安装脚本
./install.sh# 1. 复制脚本到本地
mkdir -p ~/.local/bin
cp openclaw-git.sh ~/.local/bin/openclaw-git
chmod +x ~/.local/bin/openclaw-git
# 2. 复制.gitignore到工作区
cp .gitignore ~/.openclaw/workspace/.gitignore
# 3. 初始化Git仓库
cd ~/.openclaw/workspace
git init
git config user.name "OpenClaw Agent"
git config user.email "openclaw@local"
git add .
git commit -m "Initial commit"
# 4. 复制skill文档
mkdir -p ~/.openclaw/workspace/skills/workspace-version-control
cp SKILL.md ~/.openclaw/workspace/skills/workspace-version-control/当你需要保存当前工作状态,创建一个安全回退点时:
# 创建带时间戳的备份
openclaw-git backup
# 或者创建带描述的提交
openclaw-git commit "完成重要工作,创建存档点"
# 创建永久标签(里程碑)
openclaw-git tag "v1.0-stable"输出示例:
✓ 提交成功
提交ID: abc1234
✓ 备份已创建: backup_20260329_233240
当你发现记忆被污染或配置错误,需要回退到之前的安全状态时:
# 第一步:查看历史存档点
openclaw-git log 20
# 输出示例:
# abc1234 - 备份于 2026-03-29 23:32
# def5678 - 完成WBC算法注释
# 9012345 - 初始提交
# 第二步:回退到指定存档点
openclaw-git rollback abc1234
# 或者只恢复特定文件
openclaw-git restore MEMORY.md确认提示:
警告: 这将丢失所有未提交的更改!
回退到提交: abc1234
确认回退? (y/N): y
✓ 已回退到提交 abc1234
当你需要查看历史存档点及存档时间时:
# 查看最近10个存档点
openclaw-git log 10
# 查看所有存档点
openclaw-git log 50
# 查看所有备份标签
openclaw-git tags
# 查看当前状态
openclaw-git status输出示例:
=== 最近 10 次提交 ===
* abc1234 (HEAD, tag: backup_20260329_233240) Backup at 20260329_233240
* def5678 创建workspace-version-control skill
* 9012345 Initial commit
=== 所有标签 ===
backup_20260329_233240
v1.0-stable
# 1. 创建备份
openclaw-git backup
# 2. 创建实验分支
openclaw-git branch test-new-config
# 3. 进行实验...
# 4a. 实验失败:切回主分支
git checkout master
# 4b. 实验成功:合并分支
openclaw-git merge test-new-config# 恢复特定文件
openclaw-git restore MEMORY.md
# 恢复整个目录
openclaw-git restore skills/.gitignore 文件确保以下内容不会被提交:
- ✅ 敏感信息(
*_secret*.md,*_private*.md) - ✅ 凭证文件(
credentials/,secrets/,.env) - ✅ 大文件(
*.pth,*.pt,*.onnx) - ✅ 临时文件(
*.tmp,*.log)
✅ AGENTS.md # 工作区配置
✅ USER.md # 用户信息
✅ MEMORY.md # 核心记忆
✅ IDENTITY.md # 身份设置
✅ SOUL.md # 人格设置
✅ TOOLS.md # 工具配置
✅ memory/ # 日常记忆
✅ skills/ # 自定义skill
✅ scripts/ # 工具脚本
| 命令 | 说明 | 示例 |
|---|---|---|
status |
查看当前状态 | openclaw-git status |
commit [msg] |
提交更改 | openclaw-git commit "更新记忆" |
backup |
创建备份 | openclaw-git backup |
log [n] |
查看历史 | openclaw-git log 20 |
rollback <id> |
回退版本 | openclaw-git rollback abc123 |
restore <file> |
恢复文件 | openclaw-git restore MEMORY.md |
branch <name> |
创建分支 | openclaw-git branch test |
merge <branch> |
合并分支 | openclaw-git merge test |
tag <name> |
创建标签 | openclaw-git tag v1.0 |
tags |
查看标签 | openclaw-git tags |
| 特性 | 传统Git | 本系统 |
|---|---|---|
| 对象 | 代码文件 | AI记忆、skill、配置 |
| 场景 | 软件开发 | AI agent进化 |
| 核心问题 | 代码变更 | 记忆污染、配置错误 |
| 安全重点 | 代码回退 | AI行为安全 |
| 自动化 | 手动提交 | 可自动备份 |
- ❌ LangChain:有memory模块,但无版本控制
- ❌ AutoGPT:有workspace,但无回退
- ❌ Mem0/MemGPT:专注存储,无安全机制
这是首个专门为AI agent安全设计的版本控制系统。
This is a version control system specifically designed for AI agents, solving the critical problems of memory pollution and unsafe evolution.
AI agents continuously learn and evolve:
Learn → Memorize → Evolve → Continue...
But what if:
- ❌ The AI learns incorrect information?
- ❌ Memory gets polluted?
- ❌ An unsafe skill is installed?
- ❌ Configuration breaks?
- ❌ No way to rollback!
This system provides AI agents with a "time machine":
Learn → Memorize → Version Save → Problem Detected → Rollback → Continue...
Features:
- ✅ Memory Safety: Rollback polluted memories
- ✅ Skill Safety: Revert unsafe skills
- ✅ Config Safety: Restore broken configurations
- ✅ Safe Experimentation: Branch for testing
- ✅ History Tracking: Trace all changes
# Clone the repository
git clone https://github.com/ExuberantWitness/openclaw-workspace-version-control.git
cd openclaw-workspace-version-control
# Run installation script
./install.sh# 1. Copy script to local
mkdir -p ~/.local/bin
cp openclaw-git.sh ~/.local/bin/openclaw-git
chmod +x ~/.local/bin/openclaw-git
# 2. Copy .gitignore to workspace
cp .gitignore ~/.openclaw/workspace/.gitignore
# 3. Initialize Git repository
cd ~/.openclaw/workspace
git init
git config user.name "OpenClaw Agent"
git config user.email "openclaw@local"
git add .
git commit -m "Initial commit"
# 4. Copy skill documentation
mkdir -p ~/.openclaw/workspace/skills/workspace-version-control
cp SKILL.md ~/.openclaw/workspace/skills/workspace-version-control/When you need to save current work state and create a safe rollback point:
# Create timestamped backup
openclaw-git backup
# Or create commit with description
openclaw-git commit "Completed important work, creating checkpoint"
# Create permanent tag (milestone)
openclaw-git tag "v1.0-stable"Example Output:
✓ Commit successful
Commit ID: abc1234
✓ Backup created: backup_20260329_233240
When you discover memory pollution or config errors, need to rollback to previous safe state:
# Step 1: View history checkpoints
openclaw-git log 20
# Example output:
# abc1234 - Backup at 2026-03-29 23:32
# def5678 - Completed WBC algorithm annotation
# 9012345 - Initial commit
# Step 2: Rollback to specific checkpoint
openclaw-git rollback abc1234
# Or restore specific file only
openclaw-git restore MEMORY.mdConfirmation Prompt:
Warning: This will lose all uncommitted changes!
Rollback to commit: abc1234
Confirm rollback? (y/N): y
✓ Rolled back to commit abc1234
When you need to view historical checkpoints and their timestamps:
# View recent 10 checkpoints
openclaw-git log 10
# View all checkpoints
openclaw-git log 50
# View all backup tags
openclaw-git tags
# View current status
openclaw-git statusExample Output:
=== Recent 10 commits ===
* abc1234 (HEAD, tag: backup_20260329_233240) Backup at 20260329_233240
* def5678 Created workspace-version-control skill
* 9012345 Initial commit
=== All tags ===
backup_20260329_233240
v1.0-stable
# 1. Create backup
openclaw-git backup
# 2. Create experiment branch
openclaw-git branch test-new-config
# 3. Conduct experiments...
# 4a. Experiment failed: switch back to master
git checkout master
# 4b. Experiment succeeded: merge branch
openclaw-git merge test-new-config# Restore specific file
openclaw-git restore MEMORY.md
# Restore entire directory
openclaw-git restore skills/The .gitignore file ensures these are NOT committed:
- ✅ Sensitive information (
*_secret*.md,*_private*.md) - ✅ Credential files (
credentials/,secrets/,.env) - ✅ Large files (
*.pth,*.pt,*.onnx) - ✅ Temporary files (
*.tmp,*.log)
✅ AGENTS.md # Workspace configuration
✅ USER.md # User information
✅ MEMORY.md # Core memory
✅ IDENTITY.md # Identity settings
✅ SOUL.md # Personality
✅ TOOLS.md # Tool configuration
✅ memory/ # Daily memories
✅ skills/ # Custom skills
✅ scripts/ # Tool scripts
| Command | Description | Example |
|---|---|---|
status |
Show current status | openclaw-git status |
commit [msg] |
Commit changes | openclaw-git commit "Update memory" |
backup |
Create backup | openclaw-git backup |
log [n] |
View history | openclaw-git log 20 |
rollback <id> |
Rollback version | openclaw-git rollback abc123 |
restore <file> |
Restore file | openclaw-git restore MEMORY.md |
branch <name> |
Create branch | openclaw-git branch test |
merge <branch> |
Merge branch | openclaw-git merge test |
tag <name> |
Create tag | openclaw-git tag v1.0 |
tags |
View tags | openclaw-git tags |
| Feature | Traditional Git | This System |
|---|---|---|
| Target | Source code | AI memory & config |
| Scenario | Software dev | AI evolution |
| Key Problem | Code changes | Memory pollution |
| Safety Focus | Code rollback | AI behavior safety |
| Automation | Manual commit | Auto backup |
- ❌ LangChain: Has memory modules, but no version control
- ❌ AutoGPT: Has workspace, but no rollback
- ❌ Mem0/MemGPT: Focus on storage, no safety mechanisms
This is the FIRST version control system designed specifically for AI agent safety.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- GitHub: @ExuberantWitness
- Issues: GitHub Issues
Star ⭐ this repo if you find it useful!
Made with ❤️ for the AI safety community