Agent 引导(Bootstrapping)
Bootstrapping(引导)是 Agent(智能体)首次运行时的准备仪式。当你第一次启动一个 Agent 时,OpenClaw 会通过一系列自动化步骤为它建立身份、配置工作空间,并完成初始化设置。
什么时候会触发 Bootstrapping?
只有在 Agent 的工作空间中没有身份文件时才会触发。一旦完成,后续启动不会再次执行。
Bootstrapping 的工作原理
播种阶段(Seeding)
Agent 首次运行时,OpenClaw 会在工作空间中自动生成以下文件:
| 文件 | 用途 |
|---|---|
AGENTS.md | Agent 注册表,记录所有已配置 Agent 的信息 |
BOOTSTRAP.md | 引导脚本,包含首次运行的 Q&A 流程 |
IDENTITY.md | Agent 的身份定义文件(引导完成后生成) |
USER.md | 用户信息文件,记录 Agent 的使用者偏好 |
Q&A 仪式(Ritual)
播种完成后,OpenClaw 会启动一个交互式 Q&A 仪式,引导你定义 Agent 的身份和行为:
🦞 Bootstrapping new agent...
? What should I call you? (用户称呼)
? What is my name? (Agent 名称)
? What is my primary role? (主要职责)
? What tone should I use? (沟通风格)
? Any specific instructions? (特殊指令)你的回答会被写入身份文件,成为 Agent 的"人格基础"。
身份写入(Identity Commit)
Q&A 完成后,OpenClaw 将回答内容写入工作空间的身份文件:
✅ Writing identity to IDENTITY.md
✅ Updating USER.md with preferences
✅ Registering agent in AGENTS.md
🗑️ Removing BOOTSTRAP.md (no longer needed)重要
BOOTSTRAP.md 在引导完成后会被自动删除。这是设计行为——它仅在首次运行时使用。
文件详解
AGENTS.md
Agent 注册表,记录工作空间中所有 Agent 的配置信息:
markdown
# Agents
## molty
- Model: openai:gpt-4o
- Role: General assistant
- Created: 2025-01-15
## researcher
- Model: anthropic:claude-3.5-sonnet
- Role: Research and analysis
- Created: 2025-01-16IDENTITY.md
Agent 的身份定义文件,由 Bootstrapping 过程生成:
markdown
# Identity
Name: Molty
Role: General-purpose AI assistant
Tone: Friendly and professional
Owner: Zhang San
## Instructions
- Always respond in the user's preferred language
- Prioritize accuracy over speed
- Ask for clarification when instructions are ambiguousUSER.md
用户偏好文件,帮助 Agent 了解使用者:
markdown
# User
Name: Zhang San
Preferred Language: Chinese
Timezone: Asia/ShanghaiBOOTSTRAP.md
引导脚本文件,仅在首次运行时存在:
markdown
# Bootstrap
This file controls the first-run bootstrapping process.
It will be automatically removed after bootstrapping completes.
## Questions
1. User name
2. Agent name
3. Agent role
4. Communication tone
5. Special instructions运行位置
关键概念
Bootstrapping 始终在 Gateway(网关)所在的主机上运行。即使你通过远程渠道(如 WhatsApp、Telegram)与 Agent 交互,引导过程中的文件读写操作都发生在 Gateway 主机本地。
这意味着:
- 身份文件存储在 Gateway 主机的工作空间中
- Agent 对文件系统的访问权限取决于 Gateway 主机的权限
- 远程客户端只是发送和接收消息,不直接接触文件系统
手动重新引导
如果你需要重新进行 Bootstrapping(例如重置 Agent 身份),可以:
第一步:删除身份文件
bash
rm ~/.openclaw/workspace/IDENTITY.md完全重置(删除所有 Agent 数据)
谨慎操作
以下操作会删除 Agent 的所有身份和记忆数据,不可恢复。
bash
# 删除整个工作空间
rm -rf ~/.openclaw/workspace/
# 重启 Gateway
openclaw gateway restart流程图
首次启动 Agent
│
▼
检查 IDENTITY.md
│
┌───┴───┐
│ 存在? │
└───┬───┘
│
否 │ 是
│ └──▶ 正常启动,跳过引导
▼
播种文件
(AGENTS.md, BOOTSTRAP.md, USER.md)
│
▼
Q&A 仪式
(交互式问答)
│
▼
写入 IDENTITY.md
更新 USER.md
更新 AGENTS.md
│
▼
删除 BOOTSTRAP.md
│
▼
引导完成 ✅下一步
引导向导详解了解 CLI 引导向导的完整配置流程
→个人助手设置配置 OpenClaw 作为个人助手
→