@@ -29,6 +29,23 @@ runtime:
2929 max_no_progress_streak : 5
3030 max_repeat_cycle_streak : 3
3131 max_turns : 90
32+ hooks :
33+ enabled : true
34+ user_hooks_enabled : true
35+ default_timeout_sec : 2
36+ default_failure_policy : warn_only
37+ items :
38+ - id : warn-bash
39+ enabled : true
40+ point : before_tool_call
41+ scope : user
42+ kind : builtin
43+ mode : sync
44+ handler : warn_on_tool_call
45+ priority : 100
46+ params :
47+ tool_name : bash
48+ message : " bash tool is invoked"
3249 assets :
3350 max_session_asset_bytes : 20971520
3451 max_session_assets_total_bytes : 20971520
@@ -94,9 +111,32 @@ context:
94111| `runtime.max_no_progress_streak` | 连续“无进展”轮次提醒阈值,默认 `5`;达到 `limit-1` 起会向模型注入纠偏提示,不会直接终止运行 |
95112| `runtime.max_repeat_cycle_streak` | 连续“重复调用同一工具参数”提醒阈值,默认 `3`;达到阈值后触发重复循环提醒,不会直接终止运行 |
96113| `runtime.max_turns` | 单次 Run 的最大推理轮数上限,默认 `40`;达到上限后直接终止并返回明确 stop reason |
114+ | `runtime.hooks.enabled` | hooks 总开关;关闭后不执行 runtime hooks |
115+ | `runtime.hooks.user_hooks_enabled` | user hooks 开关;关闭后不加载 `runtime.hooks.items` |
116+ | `runtime.hooks.default_timeout_sec` | user hook 默认超时秒数,需 `> 0` |
117+ | `runtime.hooks.default_failure_policy` | 默认失败策略,支持 `warn_only` / `fail_open` / `fail_closed` |
118+ | `runtime.hooks.items` | user builtin hooks 列表;仅支持 `scope=user`、`kind=builtin`、`mode=sync` |
97119| `runtime.assets.max_session_asset_bytes` | 单个 `session_asset` 最大原始字节数,默认 `20971520`(20 MiB);`0` 或未配置时回退默认值 |
98120| `runtime.assets.max_session_assets_total_bytes` | 单次请求可携带的 `session_asset` 原始总字节上限,默认 `20971520`(20 MiB);`0` 或未配置时回退默认值 |
99121
122+ # ## `runtime.hooks.items` 字段约束
123+
124+ | 字段 | 说明 |
125+ |------|------|
126+ | `id` | hook 唯一标识,同一配置文件内不可重复 |
127+ | `enabled` | 是否启用该 hook,默认 `true` |
128+ | `point` | 仅支持 `before_tool_call` / `after_tool_result` / `before_completion_decision` |
129+ | `scope` | P2 固定为 `user` |
130+ | `kind` | P2 固定为 `builtin` |
131+ | `mode` | P2 固定为 `sync` |
132+ | `handler` | 仅支持 `require_file_exists` / `warn_on_tool_call` / `add_context_note` |
133+ | `priority` | 同一 hook point 内执行优先级,数值越大越先执行 |
134+ | `timeout_sec` | 覆盖默认超时;未配置时继承 `runtime.hooks.default_timeout_sec` |
135+ | `failure_policy` | 覆盖默认失败策略;未配置时继承 `runtime.hooks.default_failure_policy` |
136+ | `params` | handler 参数;不同 handler 使用不同键 |
137+
138+ > 注意:`warn_only` 在 runtime 内部映射为 `fail_open`,表示记录失败但不阻断主链。
139+
100140# # Budget 解析规则
101141
102142NeoCode 已不再使用旧的 `auto_compact` 阈值语义,当前统一使用 `context.budget`:
0 commit comments