跳转到内容

💡 OpenClaw 高级配置

Hook 让你在 Gateway 事件发生时自动执行脚本。

事件触发时机
command:new/reset/stop命令执行时
session:compact:before/afterSession 压缩前后
agent:bootstrapAgent 启动时
gateway:startupGateway 启动时
message:received/sent/preprocessed消息收发时
{
hooks: {
gmail: { model: "anthropic/claude-opus-4-6" }
}
}
  • compact 前自动备份记忆 → QMD 查询 → 汇报 Daniel
  • 消息自动路由 → 分类、过滤、转发
  • 每次对话预处理 → 提取摘要、警报、噪音过滤

{
delivery: {
mode: "webhook",
to: "https://your-server.com/api/openclaw-hook"
}
}
Terminal window
curl -X POST http://localhost:18789/api/sessions/send \
-H "Authorization: Bearer $TOKEN" \
-d '{"sessionKey":"agent:main:telegram:user:8518085684","message":"execute task"}'
  • 飞书/Notion 收到任务完成通知后自动更新卡片
  • CI/CD 集成:PR 合并后触发代码审查
  • 异常检测推送告警到飞书群

🔄 Tool Loop Detection(循环检测)

Section titled “🔄 Tool Loop Detection(循环检测)”

防止 Agent 陷入无限循环。

{
tools: {
loopDetection: {
enabled: true,
historySize: 30,
warningThreshold: 10,
criticalThreshold: 20,
globalCircuitBreakerThreshold: 30,
detectors: {
genericRepeat: true,
knownPollNoProgress: true,
pingPong: true
}
}
}
}
检测器说明
genericRepeat同一工具 + 同一参数重复调用
knownPollNoProgress轮询无进展
pingPong交替 ping-pong 模式
  • warning: 记录警告但不阻止
  • critical: 阻止该工具调用
  • globalCircuitBreaker: 全局熔断

{
tools: {
exec: {
security: "full", // deny | allowlist | full
host: "auto", // auto | sandbox | gateway | node
elevated: true, // 跳出沙盒在主机执行
pty: true, // 支持交互式 CLI
timeout: 1800, // 默认 30 分钟
notifyOnExit: true // 后台进程退出通知
}
}
}

模式描述
off无沙箱(默认)
non-main非主 session 沙箱化
all所有 session 沙箱化

推荐: Linux VPS 上建议启用 non-mainall 模式。


优先级功能理由
P0Loop Detection防止 Agent 卡死浪费 token
P0ACP Agents直接在聊天中调用 Codex/Claude Code
P1Browser CDP提升浏览器自动化性能
P1Elevated Mode沙箱 Agent 需要主机访问
P2OpenAI HTTP API接入 Open WebUI 等第三方工具

OpenClaw 实战经验 →