Skip to content

Commit 2005957

Browse files
committed
feat(循环检测): 实现三层渐进式循环检测机制
新增 LoopDetectionService 提供工具调用、内容重复和 LLM 智能三层检测 - 层1: 工具调用循环检测 (MD5 哈希 + 动态阈值) - 层2: 内容循环检测 (滑动窗口 + 动态相似度) - 层3: LLM 智能检测 (认知循环分析) - 支持渐进式警告策略 (默认2次警告后停止) - 支持白名单工具和 Plan 模式跳过检测 - 添加完整文档说明实现细节和配置指南
1 parent 36ab285 commit 2005957

4 files changed

Lines changed: 1076 additions & 57 deletions

File tree

CLAUDE.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Root (blade-code)
9696
- 静态工厂方法 `Agent.create()` 用于创建和初始化实例
9797
- 每次命令可创建新 Agent 实例(用完即弃)
9898
- 通过 `ExecutionEngine` 处理工具执行流程
99-
- 通过 `LoopDetectionService` 防止无限循环
99+
- 通过 `LoopDetectionService` 防止无限循环(三层检测机制)
100100

101101
- **SessionContext** ([src/ui/contexts/SessionContext.tsx](src/ui/contexts/SessionContext.tsx)): 会话状态管理
102102
- 维护全局唯一 `sessionId`
@@ -129,6 +129,12 @@ Root (blade-code)
129129
- Discovery → Permission (Zod验证+默认值) → Confirmation → Execution → Formatting
130130
- 事件驱动架构,支持监听各阶段事件
131131
- 自动记录执行历史
132+
- **LoopDetectionService** ([src/agent/LoopDetectionService.ts](src/agent/LoopDetectionService.ts)): 三层循环检测系统
133+
- **层1**: 工具调用循环检测(MD5 哈希 + 动态阈值)
134+
- **层2**: 内容循环检测(滑动窗口 + 动态相似度)
135+
- **层3**: LLM 智能检测(认知循环分析)
136+
- 支持白名单工具、Plan 模式跳过内容检测
137+
- 详见: [循环检测系统文档](docs/development/implementation/loop-detection-system.md)
132138
- **PromptBuilder** ([src/prompts/](src/prompts/)): 提示模板管理和构建
133139
- **ContextManager** ([src/context/ContextManager.ts](src/context/ContextManager.ts)): 上下文管理系统
134140
- **JSONL 格式**: 追加式存储,每行一个 JSON 对象

0 commit comments

Comments
 (0)