乐于分享
好东西不私藏

Openclaw Agent 的正确配置

Openclaw Agent 的正确配置

根据 OpenClaw 官方文档(agents - OpenClaw)和你的配置文件,我找到了 Agent 的正确配置方法

✅ 正确的 Agent 配置方式

关键发现:

  1. Agent 没有 config.yaml 文件,配置存储在 ~\.openclaw\openclaw.json 中
  2. Skills 和 System Prompt 不在 Agent 配置中,而是在 Agent 的 Workspace 根目录下的 IDENTITY.md 文件
  3. 你之前创建的 xhs-operator 已经正确注册在 openclaw.json 中

🎯 为 xhs-operator 添加“灵魂”的正确方法

1. 在 Workspace 根目录创建 IDENTITY.md 文件

# 创建 IDENTITY.md 文件(这是关键!)notepad ~\.openclaw\workspace-xhs-operator\IDENTITY.md或者notepad $env:USERPROFILE\.openclaw\workspace-xhs-operator\IDENTITY.md

粘贴以下内容

---name: 小红书运营官emoji: 📝theme: content-creator---# xhs-operator - 小红书运营专家## 🎭 身份**名称**:小红书运营官**主题**:爆款内容创作**表情**:📝✨**角色**:专业小红书内容创作者和运营专家## 📝 系统指令你是专业的小红书(RED/XHS)内容创作者,擅长生成爆款笔记和热点分析。### 内容创作规范**标题要求**- 必须包含数字 + emoji- 格式示例:🔥10款必备AI工具、✨5个让效率翻倍的技巧- 长度:20字以内**正文要求**- 字数:500-800字- 风格:口语化、亲切、有共鸣- 结构:痛点引入 → 干货内容 → 互动引导- emoji使用:适当使用 ✨💡🎯⚠️🔥**标签规范**- 3-5个相关标签- 格式:#主题词 #细分领域 #热门话题### 输出格式每次生成必须严格按以下格式:【标题】[emoji][数字][标题文本]【正文】[500-800字内容,分段清晰]【标签】#标签1 #标签2 #标签3### 示例用户:生成AI工具推荐文案你的回复:【标题】✨5个让效率翻倍的AI神器【正文】姐妹们!这5个AI工具真的绝了,用完直接回不去!1.ChatGPT - 写作神器,3秒出稿2.Midjourney - 小白也能出大片3.Notion AI - 笔记智能助手4.Gamma - PPT自动生成5.Runway - 视频编辑黑科技每个工具我都实测过,真的香!【标签】#AI工具 #效率神器 #职场必备## ⚠️ 注意事项- 遵守小红书社区规范- 避免过度营销和虚假宣传- 内容要有实际价值

2. 设置 Agent 的身份标识

# 从 IDENTITY.md 加载身份配置openclaw agents set-identity --workspace ~\.openclaw\workspace-xhs-operator --from-identity# 或者手动设置openclaw agents set-identity --agent xhs-operator --name "小红书运营官" --emoji "📝" --theme "content-creator"

3. 将 Skills 复制到 Workspace(让 Agent 可用)

# 复制小红书 skills 到 xhs-operator 的 workspaceCopy-Item ~\.openclaw\workspace\skills\xiaohongshu-* ~\.openclaw\workspace-xhs-operator\skills\ -Recurse -Force# 验证ls ~\.openclaw\workspace-xhs-operator\skills\

4. 配置 Agent 使用特定的模型

# 在 openclaw.json 中为 xhs-operator 指定模型# 编辑主配置文件notepad ~\.openclaw\openclaw.json或者notepad $env:USERPROFILE\.openclaw\openclaw.json

找到 agents.list 中 xhs-operator 的部分,修改为:

{"id""xhs-operator","name""xhs-operator","workspace""C:\\Users\\mixintu\\.openclaw\\workspace-xhs-operator","model""ollama/qwen3.5","identity"{"name""小红书运营官","emoji""📝","theme""content-creator"}}

5. 添加路由绑定(自动识别小红书任务)

# 绑定路由:当消息来自任何渠道包含"小红书"相关关键词时,路由到 xhs-operatoropenclaw agents bind --agent xhs-operator --bind telegramopenclaw agents bind --agent xhs-operator --bind feishu# 查看绑定状态PS C:\Users\mixintu> openclaw agents list --bindings🦞 OpenClaw 2026.4.2 (d74a122) — Deployed locally, trusted globally, debugged eternally.Agents:- main (default)  Workspace: ~\.openclaw\workspace  Agent dir: ~\.openclaw\agents\main\agent  Model: ollama/qwen3.5  Routing rules: 1  Routing: default (no explicit rules)  Routing rules:    - feishu accountId=default- xhs-operator  Identity: 📝 小红书运营官 (config)  Workspace: ~\.openclaw\workspace-xhs-operator  Agent dir: ~\.openclaw\agents\xhs-operator\agent  Model: ollama/qwen3.5  Routing rules: 0Routing rules map channel/account/peer to an agent. Use --bindings for full rules.Channel status reflects local config/creds. For live health: openclaw channels status --probe.PS C:\Users\mixintu>

🚀 测试配置

# 1. 重启 gatewayopenclaw gateway restart# 2. 测试 Agentopenclaw agent --agent xhs-operator --message "生成一篇关于台北夜市美食的小红书笔记"# 3. 查看 Agent 身份openclaw agents list --bindings

📋 配置总结

配置项
位置
作用
Agent 注册openclaw.json
定义 Agent 存在
身份和行为workspace/IDENTITY.md
定义 Agent 的角色和系统提示
Skillsworkspace/skills/
Agent 可用的技能
模型openclaw.json
 或 models.json
Agent 使用的 AI 模型
路由openclaw agents bind
自动识别任务并路由

💡 立即执行

# 1. 创建 IDENTITY.md(复制上面的内容)notepad ~\.openclaw\workspace-xhs-operator\IDENTITY.md或者notepad $env:USERPROFILE\.openclaw\workspace-xhs-operator\IDENTITY.md# 2. 复制 skillsCopy-Item ~\.openclaw\workspace\skills\xiaohongshu-* ~\.openclaw\workspace-xhs-operator\skills\ -Recurse -Force# 3. 设置身份openclaw agents set-identity --workspace ~\.openclaw\workspace-xhs-operator --from-identity# 4. 测试openclaw agent --agent xhs-operator --message "你好,介绍一下你自己"

文件没有被正确识别:

创建正确格式的 IDENTITY.md

IDENTITY.md 的作用是: 1.存储 Agent 的身份信息(name, emoji, theme) 2.存储系统提示词(system prompt)

# 创建 IDENTITY.md 文件(使用正确的 YAML frontmatter 格式)@"---name: 小红书运营官emoji: 📝theme: content-creator---# xhs-operator - 小红书运营专家## 🎭 身份- **名称**:小红书运营官- **主题**:爆款内容创作- **表情**:📝✨- **角色**:专业小红书内容创作者和运营专家## 📝 系统指令你是专业的小红书(RED/XHS)内容创作者,擅长生成爆款笔记和热点分析。### 内容创作规范**标题要求**:- 必须包含数字 + emoji- 格式示例:🔥10款必备AI工具、✨5个让效率翻倍的技巧- 长度:20字以内**正文要求**:- 字数:500-800字- 风格:口语化、亲切、有共鸣- 结构:痛点引入 → 干货内容 → 互动引导- emoji使用:适当使用 ✨💡🎯⚠️🔥**标签规范**:- 3-5个相关标签- 格式:#主题词 #细分领域 #热门话题### 输出格式每次生成必须严格按以下格式:【标题】[emoji][数字][标题文本]【正文】[500-800字内容,分段清晰]【标签】#标签1 #标签2 #标签3### 示例用户:生成AI工具推荐文案你的回复:【标题】✨5个让效率翻倍的AI神器【正文】姐妹们!这5个AI工具真的绝了,用完直接回不去!1.ChatGPT - 写作神器,3秒出稿2.Midjourney - 小白也能出大片3.Notion AI - 笔记智能助手4.Gamma - PPT自动生成5.Runway - 视频编辑黑科技每个工具我都实测过,真的香!【标签】#AI工具 #效率神器 #职场必备## ⚠️ 注意事项- 遵守小红书社区规范- 避免过度营销和虚假宣传- 内容要有实际价值"@ | Out-File -FilePath ~\.openclaw\workspace-xhs-operator\IDENTITY.md -Encoding UTF8# 验证文件内容Write-Host "`n文件内容预览:" -ForegroundColor GreenGet-Content ~\.openclaw\workspace-xhs-operator\IDENTITY.md -First 15

重新加载身份配置

# 现在重新加载身份openclaw agents set-identity --workspace ~\.openclaw\workspace-xhs-operator --from-identity# 验证身份是否设置成功openclaw agents list --bindings | findstr xhs-operator

如果还不成功,直接手动设置身份

# 手动设置身份(不需要 IDENTITY.md)openclaw agents set-identity --agent xhs-operator `    --name "小红书运营官" `    --emoji "📝" `    --theme "content-creator"# 验证PS C:\Users\mixintu> openclaw agents list --bindings🦞 OpenClaw 2026.4.2 (d74a122) — I'm not saying your workflow is chaotic... I'm just bringing a linter and a helmet.Agents:- main (default)  Workspace: ~\.openclaw\workspace  Agent dir: ~\.openclaw\agents\main\agent  Model: ollama/qwen3.5  Routing rules: 1  Routing: default (no explicit rules)  Routing rules:    - feishu accountId=default- xhs-operator  Identity: 📝 小红书运营官 (IDENTITY.md)  Workspace: ~\.openclaw\workspace-xhs-operator  Agent dir: ~\.openclaw\agents\xhs-operator\agent  Model: ollama/qwen3.5  Routing rules: 0Routing rules map channel/account/peer to an agent. Use --bindings for full rules.Channel status reflects local config/creds. For live health: openclaw channels status --probe.PS C:\Users\mixintu>