CellSpec 循环检测配置
wesgine 的 CellSpec 级别 CycleDetect 配置参考。
配置结构
CellSpec.CycleDetect 控制 Cell 级别的循环检测策略。
CycleDetectConfig {
ExplorationWarnThreshold int
ExplorationTermThreshold int
ActionWarnThreshold int
ActionTermThreshold int
IdenticalCallWarnThreshold int
IdenticalCallTermThreshold int
ToolOverrides map[string][2]int
ExtraCategories map[string]ToolCategoryHint
ExtraProgressAware []string
}
工具分类
CycleDetector 将工具分为三类:
| 分类 | 说明 | 典型工具 |
|---|---|---|
| Exploration | 只读/信息获取 | read、grep、search_files |
| Action | 有副作用的操作 | edit、write、exec |
| Plan | 计划管理 | plan |
分类优先级
- 硬编码 map:wesgine 内置 ~20 个工具
- ExtraCategories:消费方显式声明
- ToolMeta 自动推断:
ReadOnly=true→ exploration - 默认:action
两阶段终止
| 阶段 | 触发 | 行为 |
|---|---|---|
| 自愈 | 首次 CycleTerm | 注入纠正消息 + 重置 counter |
| HITL | 第二次 CycleTerm | 问用户,超时 60s 终止 |
ToolOverrides
为特定工具覆盖阈值:
ToolOverrides: map[string][2]int{
"exec": {30, 60},
"exec:readonly": {50, 100},
"edit": {30, 60},
}
键格式:工具名或 工具名:readonly。
值:[WarnThreshold, TermThreshold]。
Progress-Aware 工具
ExtraProgressAware 列表中的工具,当参数变化时 streak 减半。
这防止连续编辑同一文件被误判为循环。
per-Run 覆盖
AppRunRequest.CycleDetectOverride 可以 per-Run 覆盖。
委派子 Run 可以使用更严格的阈值。
消费方配置示例
wescode
编程场景阈值较高(edit 同文件 20+ 次正常):
ExplorationTermThreshold: 100
ActionTermThreshold: 50
teleclaw
企业场景使用默认值。
与 ErrorStreak 的关系
CycleDetector 检测「完全相同的重复」。
ErrorStreak 检测「表面有变化但实质无进展」。
两者互补,不重叠。