Workspace(工作空间)是 OpenClaw Agent 的家目录,是文件工具和工作空间上下文的唯一工作目录。它不仅是存储配置的地方,更是 Agent 的记忆载体,包含了身份、用户信息、长期记忆等关键文件。
workspace/
├── SOUL.md # Agent 的灵魂和个性
├── USER.md # 用户信息和偏好
├── IDENTITY.md # Agent 身份信息
├── AGENTS.md # 工作空间配置和行为准则
├── MEMORY.md # 长期记忆文件
├── TOOLS.md # 本地工具配置
├── HEARTBEAT.md # 心跳检查清单
├── BOOTSTRAP.md # 初始设置文件(首次运行后删除)
├── memory/ # 每日记忆目录
│ ├── 2026-03-20.md # 当天记忆
│ └── ... # 其他日期记忆
└── skills/ # 自定义技能目录
└── custom-skill/ # 自定义技能
└── SKILL.md # 技能元数据
Agent 可以在工作空间中进行各种文件操作:
# 读取文件
read("MEMORY.md")
# 写入文件
write("memory/2026-03-20.md", "今天完成了重要任务...")
# 编辑文件
edit("USER.md", oldText="旧内容", newText="新内容")
# 创建目录
exec("mkdir -p projects/my-project")
工作空间文件会被自动注入到 Agent 的上下文中:
# 安全策略配置
{
"security": {
"fileAccess": "workspace-only",
"execCommands": ["read", "write", "edit"],
"denyAbsolutePaths": true
}
}
~/.openclaw/ # 系统配置目录
├── config.json # 全局配置
├── credentials/ # 凭证存储
├── sessions/ # 会话历史
└── agents/ # Agent 配置
└── my-agent/ # 特定 Agent 配置
└── workspace/ # ← 这就是工作空间
├── SOUL.md
├── USER.md
└── ...
# IDENTITY.md 示例
- **Name:** ClawAssistant
- **Creature:** AI Assistant
- **Vibe:** Helpful and efficient
- **Emoji:** 🦞
- **Avatar:** avatars/claw.png
包含重要的长期信息,如:
记录每天的具体活动和事件:
# memory/2026-03-20.md 示例
## 2026-03-20 活动记录
### 上午
- 处理了用户关于 OpenClaw 架构的问题
- 创建了 Gateway、Agent、Skill 等组件页面
### 下午
- 测试了 GPT-5.4 模型连接
- 修复了网站 404 问题
### 晚上
- 完成了 OpenClaw 组件文档系统
# 创建新 Agent 工作空间
openclaw agents create my-new-agent
# 备份整个工作空间
cp -r ~/.openclaw/agents/my-agent/workspace ~/backup/
# 或使用 Git
cd ~/.openclaw/agents/my-agent/workspace
git init
git add .
git commit -m "Initial backup"
可以从备份恢复,或者重新初始化工作空间。重要的是定期备份 MEMORY.md 和其他关键文件。