Skip to content

会话通知(config.jsonnotifications

在工具结果或 assistant 回合结束时,向 HTTP URL 和/或 shell 命令(stdin) 发送 JSON。与 memory.pipeline.hook_*(嵌入/记忆侧)解耦

字段(摘要)

字段含义
after_tool_result每条工具结果后是否触发(需已配置投递方式)。
after_agent_turn本轮 assistant 结束且无后续 tool_calls 时是否触发。
http_url仅允许 http / https 的 POST,正文为 JSON。
http_timeout_msHTTP 客户端超时。
http_headers额外头;值中 ${VAR} 从环境展开(未设置则为空串)。
shell_commandUnix:/bin/sh -c;Windows:cmd /Cstdin 写入 JSON(UTF-8)。
shell_timeout_ms子进程墙钟超时。
max_body_bytes限制序列化后的 excerpt;合法范围为 256–524288
tool_deny_prefixes工具名以前缀匹配则跳过(如 mcp__)。

http_url / shell_command 若为空或仅空白,视为未配置该通道(与代码 is_configured() 一致)。

JSON 载荷

每次投递含 schema_version: 1 与唯一 event_id(UUID 字符串),便于网关去重。

json
{
  "schema_version": 1,
  "event_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
  "event": "tool_result",
  "session_id": "…",
  "task_id": "…",
  "turn": 2,
  "tool_name": "bash",
  "excerpt": "…",
  "excerpt_truncated": false,
  "timestamp": "2026-04-20T12:00:00.000Z",
  "working_directory": "/path/to/project"
}

memory.pipeline 钩子的区别

notificationsmemory.pipeline.hook_*
用途出站集成(网关、脚本)记忆/嵌入管线
载荷版本化 JSON(schema_versionevent_id 等)管线专用
失败仅日志;阻断编排依钩子实现而定

OpenClaw 网关最小对接

http_url 指向网关(如 https://gateway.example/hooks/anycode)。可在 http_headers 中设置 Authorization: Bearer ${OPENCLAW_TOKEN}。服务端应 POST 接收 JSON、返回 2xx,并按需用 event_id 做幂等。

可观测性

tracing debug、target anycode_session_notify:记录 HTTP hosteventexcerpt_truncatedelapsed_ms(不记录完整 excerpt 或密钥)。

English: Session notifications.

MIT License