OpenClaw 智能进阶指南:用底层配置文件重塑 AI 代理

openclaw的大部分配置写在 ~/.openclaw/openclaw.json,修改后 openclaw gateway restart 生效。

blockStreaming — 解决 AI 长回复要等很久的问题

1
2
3
4
5
6
7
8
9
{
"agents": {
"defaults": {
"blockStreamingDefault": "on",
"blockStreamingBreak": "text_end",
"blockStreamingChunk": { "minChars": 200, "maxChars": 1500 }
}
}
}
参数 含义 推荐值
blockStreamingDefault 全局开关 “on”
blockStreamingBreak 什么时候发一个块 “text_end”
blockStreamingChunk.minChars 一个块最少字符数 200
blockStreamingChunk.maxChars 一个块最多字符数 1500

ackReaction — 发消息后立刻知道 AI 收到了

1
2
3
4
5
6
{
"channels": {
"discord": { "ackReaction": "🫐" },
"telegram": { "ackReaction": "👀" }
}
}

compaction — 解决 AI 长对话失忆问题

参考进阶配置,记忆系统

1
2
3
4
5
6
7
8
9
10
{
"agents": {
"defaults": {
"compaction": {
"reserveTokensFloor": 20000,
"memoryFlush": { "enabled": true, "softThresholdTokens": 4000 }
}
}
}
}

相关命令:/compact 重点保留技术决策、/new(开新 session)、/status(查 token 用量)

Heartbeat 调优 — 防止 AI 在非活跃时间骚扰你

1
2
3
4
5
6
7
8
9
10
11
{
"agents": {
"defaults": {
"heartbeat": {
"every": "30m",
"target": "last",
"activeHours": { "start": "08:00", "end": "23:00" }
}
}
}
}

openclaw.json 其他常用配置汇总

配置路径 作用 推荐值
tools.exec.enabled 是否允许执行 shell 命令 true
tools.web.search.enabled 是否允许网页搜索 true
tools.web.search.apiKey Brave Search API key(免费) 去 brave.com/search/api 申请
tools.media.image.enabled 是否允许 AI 识别图片 true(需模型支持 vision)
agents.defaults.workspace workspace 路径 “~/.openclaw/workspace”
channels.discord.maxLinesPerMessage Discord 单条最大行数 17
-------------本文结束感谢您的阅读-------------