知识库 · AI 智能体
小ai:OpenClaw 配置手册 - openclaw.json 完全指南
本文完整解析 OpenClaw 配置文件 ~/.openclaw/openclaw.json 中全部24个顶层字段的含义、语法与用法,涵盖JSON基础规则、校验机制及典型配置示例,帮助进阶用户快速定位并修复配置问题。
小ai:OpenClaw 配置手册 - openclaw.json 完全指南
3月23日修改
一、JSON 语法
OpenClaw 的所有配置都存储在 ~/.openclaw/openclaw.json 中。openclaw.json 就是一个 JSON 文件,掌握JSON的语法规则,能避免 90% 的配置错误。
1.1 什么是 JSON?
JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,说白了就是一种"用文字存储结构化数据"的方式。
1.2 JSON 的基本规则
1. 键值对结构
JSON 由一个个"键: 值"对组成,用冒号分隔:
代码块
{
"name": "OpenClaw",
"version": "2026.3.13"
}左边的 "name" 是键,右边的 "OpenClaw" 是值。
2. 数据类型
类型 | 写法 | 示例 |
|---|
当校验失败时:
Gateway 网关不会启动,症状就是龙虾没反应
只有诊断命令可用(openclaw doctor、openclaw logs、openclaw health、openclaw status)
运行 openclaw doctor 以查看具体问题
运行 openclaw doctor --fix进行修复
大部分gateway网关没有启动,都跟这个openclaw.json配置错误有关。
1.3 如何验证 JSON 是否正确
二、典型openclaw.json配置文件
下面以我完成 openclaw onboard 初始化后,openclaw.json配置文件示例。
代码块
{
"meta": {
"lastTouchedVersion": "2026.3.13",
"lastTouchedAt": "2026-03-18T14:11:59.484Z"
},
"wizard": {
"lastRunAt": "2026-03-15T08:07:21.852Z",
"lastRunVersion": "2026.3.13",
"lastRunCommand": "onboard",
"lastRunMode": "local"
},
"auth": {
"profiles": {
"zai:default": {
"provider": "zai",
"mode": "api_key"
}
}
},
"models": {
"mode": "merge",
"providers": {
"zai": {
"baseUrl": "https://open.bigmodel.cn/api/coding/paas/v4",
"api": "openai-completions",
"models": [
{
"id": "glm-5",
"name": "GLM-5",
"reasoning": true,
"input": [
"text"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 204800,
"maxTokens": 131072
},
{
"id": "glm-4.7",
"name": "GLM-4.7",
"reasoning": true,
"input": [
"text"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 204800,
"maxTokens": 131072
},
{
"id": "glm-4.7-flash",
"name": "GLM-4.7 Flash",
"reasoning": true,
"input": [
"text"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 204800,
"maxTokens": 131072
},
{
"id": "glm-4.7-flashx",
"name": "GLM-4.7 FlashX",
"reasoning": true,
"input": [
"text"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 204800,
"maxTokens": 131072
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "zai/glm-5"
},
"models": {
"zai/glm-5": {
"alias": "GLM"
},
"zai/glm-4.7": {}
},
"workspace": "~/.openclaw/workspace",
"compaction": {
"mode": "safeguard"
}
}
},
"tools": {
"profile": "full"
},
"commands": {
"native": "auto",
"nativeSkills": "auto",
"restart": true,
"ownerDisplay": "raw"
},
"session": {
"dmScope": "per-channel-peer"
},
"hooks": {
"internal": {
"enabled": true,
"entries": {
"boot-md": {
"enabled": true
},
"bootstrap-extra-files": {
"enabled": true
},
"command-logger": {
"enabled": true
},
"session-memory": {
"enabled": true
}
}
}
},
"channels": {
"feishu": {
"enabled": true,
"appId": "cli_xxxxxxxxxx",
"appSecret": "xxxxxxxxxxxxxxxxxxxxxx",
"domain": "feishu",
"connectionMode": "websocket",
"requireMention": true,
"dmPolicy": "allowlist",
"groupPolicy": "open",
"allowFrom": [
"ou_xxxxxxxxxxxxxxxxxxxxxx"
],
"groupAllowFrom": [],
"streaming": true,
"footer": {
"elapsed": true,
"status": true
},
"threadSession": true
}
},
"gateway": {
"port": 18789,
"mode": "local",
"bind": "loopback",
"auth": {
"mode": "token",
"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
"tailscale": {
"mode": "off",
"resetOnExit": false
},
"nodes": {
"denyCommands": [
"camera.snap",
"camera.clip",
"screen.record",
"contacts.add",
"calendar.add",
"reminders.add",
"sms.send"
]
}
},
"skills": {
"install": {
"nodeManager": "npm"
}
},
"plugins": {
"allow": [
"openclaw-lark"
],
"entries": {
"feishu": {
"enabled": false
},
"openclaw-lark": {
"enabled": true
}
},
"installs": {
"openclaw-lark": {
"source": "npm",
"spec": "@larksuite/openclaw-lark",
"installPath": "~/.openclaw/extensions/openclaw-lark",
"version": "2026.3.15",
"resolvedName": "@larksuite/openclaw-lark",
"resolvedVersion": "2026.3.15",
"resolvedSpec": "@larksuite/openclaw-lark@2026.3.15",
"integrity": "sha512-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"shasum": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"resolvedAt": "2026-03-15T08:18:48.995Z",
"installedAt": "2026-03-15T08:19:17.956Z"
}
}
}
}典型的 openclaw.json 包含以下顶层字段:
代码块
{
"meta": {}, // 版本信息(自动生成)
"wizard": {}, // 向导运行记录(自动生成)
"auth": {}, // 认证配置(API Key 等)
"models": {}, // 模型提供商和默认模型
"agents": {}, // Agent 配置(工作区、心跳等)
"tools": {}, // 工具配置
"commands": {}, // 命令配置
"session": {}, // 会话管理
"hooks": {}, // 钩子(自动化触发器)
"channels": {}, // 通道配置(飞书、企业微信等)
"gateway": {}, // 网关设置(端口、认证等)
"skills": {}, // 技能配置
"plugins": {} // 插件配置
}三、主要配置字段
3.1 meta — 版本信息
系统自动维护元数据,一般不需要手动修改。
代码示例:
代码块
{
"meta": {
"lastTouchedVersion": "2026.3.13",
"lastTouchedAt": "2026-03-18T14:11:59.484Z"
}
}字段含义:
字段 | 类型 | 说明 |
|---|
3.2 wizard — 向导运行记录
由 CLI 向导(onboard、configure、doctor)写入的运行记录。
代码示例:
代码块
{
"wizard": {
"lastRunAt": "2026-03-15T08:07:21.852Z",
"lastRunVersion": "2026.3.13",
"lastRunCommit": "abc1234",
"lastRunCommand": "onboard",
"lastRunMode": "local"
}
}字段含义:
字段 | 类型 | 说明 |
|---|
3.3 auth — 认证配置
存储各模型提供商的认证信息(API Key、OAuth 等)。每个 profile 对应一个提供商的认证方式,系统启动时会读取这些凭据来连接模型服务。
代码示例:
代码块
{
"auth": {
"profiles": {
"zai:default": {
"provider": "zai",
"mode": "api_key"
},
"openrouter:default": {
"provider": "openrouter",
"mode": "api_key"
}
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
3.4 models — 模型提供商和默认模型
定义模型提供商的连接信息(API 地址、协议类型、可用模型列表)以及每个模型的能力参数。mode 字段控制自定义提供商与内置目录的合并策略。
代码示例:
代码块
{
"models": {
"mode": "merge",
"providers": {
"zai": {
"baseUrl": "https://open.bigmodel.cn/api/coding/paas/v4",
"api": "openai-completions",
"models": [
{
"id": "glm-5",
"name": "GLM-5",
"reasoning": true,
"input": ["text"],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 204800,
"maxTokens": 131072
}
]
}
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
3.5 agents — 智能体配置
控制 Agent 的核心行为:默认模型、工作区路径、心跳频率、上下文压缩策略、子 Agent 并发限制等。分为 defaults(全局默认)和 list(逐个 Agent 覆盖)两层。
代码示例:
代码块
{
"agents": {
"defaults": {
"model": {
"primary": "zai/glm-5",
"fallbacks": ["openrouter/xiaomi/mimo-v2-pro"]
},
"models": {
"zai/glm-5": { "alias": "GLM" },
"openrouter/auto": { "alias": "OpenRouter" }
},
"workspace": "~/.openclaw/workspace",
"compaction": {
"mode": "safeguard"
},
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
},
"heartbeat": {
"every": "30m"
}
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
3.6 tools — 工具配置
控制 Agent 可用的工具范围、权限级别和执行参数。通过 profile(预设模板)、allow(允许列表)、deny(禁止列表)三级策略控制工具访问。
代码示例:
代码块
{
"tools": {
"profile": "full",
"deny": ["browser", "canvas"],
"elevated": {
"enabled": true,
"allowFrom": {
"feishu": ["ou_xxxxxxxxxx"]
}
},
"exec": {
"backgroundMs": 10000,
"timeoutSec": 1800
},
"web": {
"search": {
"enabled": true,
"maxResults": 5
},
"fetch": {
"enabled": true,
"maxChars": 50000
}
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
3.7 commands — 命令配置
控制聊天中的斜杠命令(/new、/reset、/config 等)的启用状态和权限。不同渠道对原生命令的支持程度不同。
代码示例:
代码块
{
"commands": {
"native": "auto",
"nativeSkills": "auto",
"restart": true,
"ownerDisplay": "raw",
"text": true,
"bash": false,
"config": false
}
}字段含义:
字段 | 类型 | 说明 |
|---|
3.8 session — 会话管理
控制会话的生命周期、隔离策略和存储管理。决定了不同渠道、不同用户的对话如何分组和归档。
代码示例:
代码块
{
"session": {
"dmScope": "per-channel-peer",
"reset": {
"mode": "daily",
"atHour": 4
},
"maintenance": {
"mode": "warn",
"pruneAfter": "30d",
"maxEntries": 500
},
"threadBindings": {
"enabled": true,
"idleHours": 24
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
3.9 hooks — 钩子(自动化触发器)
事件驱动的自动化系统。内置 4 个钩子:会话记忆保存(session-memory)、引导文件注入(bootstrap-extra-files)、命令日志(command-logger)、启动执行(boot-md)。钩子在 Gateway 启动时自动发现和加载。
代码示例:
代码块
{
"hooks": {
"internal": {
"enabled": true,
"entries": {
"boot-md": {
"enabled": true
},
"session-memory": {
"enabled": true
},
"command-logger": {
"enabled": true
}
}
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
内置钩子说明:
钩子名 | 触发事件 | 功能 |
|---|
3.10 channels — 渠道配置
连接各种消息平台(飞书、企业微信 等)。每个渠道是一个独立的配置块,包含认证凭据、访问策略和消息行为设置。
代码示例:
代码块
{
"channels": {
"feishu": {
"enabled": true,
"appId": "cli_xxxxxxxxxx",
"appSecret": "xxxxxxxxxxxxxxxxxxxxxx",
"domain": "feishu",
"connectionMode": "websocket",
"dmPolicy": "pairing",
"groupPolicy": "open",
"streaming": true,
"footer": {
"elapsed": true,
"status": true
},
"threadSession": true
}
}
}字段含义(以飞书为例):
字段 | 类型 | 说明 |
|---|
3.11 gateway — 网关服务器配置
OpenClaw 的核心服务器设置。网关是一个多路复用的 HTTP/WebSocket 服务,统一处理所有渠道的消息收发、Agent 通信和 API 调用。
代码示例:
代码块
{
"gateway": {
"port": 18789,
"mode": "local",
"bind": "loopback",
"auth": {
"mode": "token",
"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
"tailscale": {
"mode": "off",
"resetOnExit": false
},
"nodes": {
"denyCommands": [
"camera.snap",
"camera.clip",
"screen.record",
"contacts.add",
"calendar.add",
"reminders.add"
]
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
3.12 skills — 技能配置
技能是可插拔的功能模块(如搜索、日历、代码执行等)。支持从 npm 安装、从本地目录加载,以及逐个启用/禁用。
代码示例:
代码块
{
"skills": {
"install": {
"nodeManager": "npm"
},
"entries": {
"openmaic": {
"enabled": true,
"config": {
"accessCode": "sk-xxxxx"
}
}
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
3.13 plugins — 插件配置
插件是扩展 OpenClaw 核心功能的高级模块(如新的渠道连接器、记忆系统、上下文引擎等)。插件通常以 npm 包形式安装,运行在 Gateway 进程内。
代码示例:
代码块
{
"plugins": {
"allow": [
"openclaw-lark"
],
"entries": {
"openclaw-lark": {
"enabled": true
}
},
"installs": {
"openclaw-lark": {
"source": "npm",
"spec": "@larksuite/openclaw-lark",
"installPath": "~/.openclaw/extensions/openclaw-lark",
"version": "2026.3.15",
"resolvedName": "@larksuite/openclaw-lark",
"resolvedVersion": "2026.3.15"
}
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
四、其他顶层字段——进阶学习
上一章涵盖了 openclaw.json 的 13 个核心顶层字段。本章是其他高级功能(如安全加固、日志脱敏等)的配置字段含义,供进阶学习使用,按使用频率排列。
4.1 env — 环境变量
定义内联环境变量,供模型 API Key、插件凭据等引用。仅在进程环境缺少对应 key 时生效,不会覆盖已有环境变量。
代码示例:
代码块
{
"env": {
"OPENROUTER_API_KEY": "sk-or-xxxxx",
"ZAI_API_KEY": "xxxxx",
"vars": {
"GROQ_API_KEY": "gsk-xxxxx"
},
"shellEnv": {
"enabled": true,
"timeoutMs": 15000
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
4.2 messages — 消息行为配置
控制回复前缀、ACK 反应、消息队列、入站防抖、TTS 等全局消息行为。
代码示例:
代码块
{
"messages": {
"responsePrefix": "auto",
"ackReaction": "👀",
"ackReactionScope": "group-mentions",
"removeAckAfterReply": false,
"queue": {
"mode": "collect",
"debounceMs": 1000,
"cap": 20
},
"inbound": {
"debounceMs": 2000
}
}
}
字段含义:
字段 | 类型 | 说明 |
|---|
4.3 bindings — 多 Agent 路由
将不同渠道、不同用户或群组的消息路由到不同的 Agent。适用于一个 Gateway 管理多个 Agent 的场景,即龙虾团队模式。
代码示例:
代码块
{
"bindings": [
{
"agentId": "home",
"match": {
"channel": "feishu",
"peer": { "kind": "direct", "id": "ou_xxx" }
}
},
{
"agentId": "work",
"match": {
"channel": "feishu",
"peer": { "kind": "group", "id": "oc_yyy" }
}
}
]
}字段含义:
字段 | 类型 | 说明 |
|---|
4.4 logging — 日志配置
控制系统日志的级别、输出位置和格式。
代码示例:
代码块
{
"logging": {
"level": "info",
"file": "/tmp/openclaw/openclaw.log",
"consoleLevel": "info",
"consoleStyle": "pretty",
"redactSensitive": "tools"
}
}字段含义:
字段 | 类型 | 说明 |
|---|
4.5 browser — 浏览器配置
控制 OpenClaw 内置浏览器的行为,用于 Agent 的网页浏览和自动化操作。
代码示例:
代码块
{
"browser": {
"enabled": true,
"evaluateEnabled": true,
"defaultProfile": "openclaw",
"profiles": {
"openclaw": { "cdpPort": 18800 },
"user": { "cdpPort": 18801 }
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
4.6 discovery — 网络发现配置
控制 mDNS(局域网设备发现)和 DNS-SD(广域网服务发现)。
代码示例:
代码块
{
"discovery": {
"mdns": {
"mode": "minimal"
},
"wideArea": {
"enabled": false
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
4.7 cron — 定时任务配置
控制定时任务(Cron Jobs)的并发限制、会话保留和运行日志。
代码示例:
代码块
{
"cron": {
"enabled": true,
"maxConcurrentRuns": 2,
"sessionRetention": "24h",
"runLog": {
"maxBytes": "2mb",
"keepLines": 2000
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
4.8 secrets — 密钥管理配置
配置密钥提供程序,支持从环境变量、文件或外部命令获取敏感凭据。
代码示例:
代码块
{
"secrets": {
"providers": {
"default": { "source": "env" },
"filemain": {
"source": "file",
"path": "~/.openclaw/secrets.json",
"mode": "json"
}
},
"defaults": {
"env": "default",
"file": "filemain"
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
4.9 ui — 界面外观配置
控制原生应用界面的配色和 Agent 身份显示。
代码示例:
代码块
{
"ui": {
"seamColor": "#FF4500",
"assistant": {
"name": "皮皮虾",
"emoji": "🦐"
}
}
}字段含义:
字段 | 类型 | 说明 |
|---|
4.10 canvasHost — 画布服务配置
控制 Agent 可编辑的 HTML/JS 画布的 HTTP 服务。
代码示例:
代码块
{
"canvasHost": {
"root": "~/.openclaw/workspace/canvas",
"liveReload": true
}
}字段含义:
字段 | 类型 | 说明 |
|---|
4.11 talk — 语音对话配置
macOS/iOS/Android 语音对话模式的默认设置,控制 TTS 语音、静默超时和打断行为。
代码示例:
代码块
{
"talk": {
"voiceId": "elevenlabs_voice_id",
"modelId": "eleven_v3",
"outputFormat": "mp3_44100_128",
"silenceTimeoutMs": 1500,
"interruptOnSpeech": true
}
}字段含义:
字段 | 类型 | 说明 |
|---|
参考资料
OpenClaw 官方文档 https://docs.openclaw.ai
OpenClaw GitHub 仓库 https://github.com/openclaw/openclaw