Fix/tool call circuit breaker 5234 - #5242
Conversation
…ing pattern, turn cap
|
@qwen-code /triage |
|
Thanks for the PR, @aspnmy! This addresses a real pain point — tool call infinite loops (#5234) are a known problem class and the always-on circuit breaker approach is the right direction. TemplateAll headings are present, but every section is still the unfilled placeholder comment. The reviewer test plan, motivation, risk assessment, and linked issues are all blank. Please fill in the template — it's how reviewers understand what you changed and why. The title references #5234 but there's no DirectionAligned. The issue #5234 triage identified Scope — this needs splittingThe PR bundles three unrelated changes in 15 files, but only 5 files relate to the circuit breaker: Core fix (keep in this PR):
Unrelated — please split into separate PRs:
Bug: wrong LoopType in checkTurnToolCallCap
Flagging the scope split and the LoopType bug before diving into code review. Once those are addressed, moving on to Stage 2. 🔍 中文说明感谢 @aspnmy 的 PR!这解决了真实的痛点——工具调用死循环(#5234)是已知问题类别,始终开启的断路器方案方向正确。 模板所有标题都在,但每个部分仍是未填写的占位注释。请填写模板——这是审查者理解你改了什么、为什么改的依据。标题引用了 #5234 但正文中没有 方向对齐。#5234 的 triage 确认了 范围——需要拆分PR 把三个无关改动打包在 15 个文件中,但只有 5 个文件与断路器相关: 核心修复(保留在此 PR):
无关改动——请拆分为独立 PR:
Bug:checkTurnToolCallCap 使用了错误的 LoopType
在进入代码审查之前,先标记范围拆分和 LoopType bug。解决后进入 Stage 2。🔍 — Qwen Code · qwen3.7-max |
Code ReviewIndependent proposal (before reading the diff): For tool call infinite loops with Assessment: the core approach is sound and matches my independent proposal. The integration point is correct (before the gate), the three new detectors cover the main loop variants, and the test coverage is thorough. Issues found1. Bug (blocker): Wrong private checkTurnToolCallCap(_toolCallKey: string): boolean {
this.turnToolCallTotal++;
if (this.turnToolCallTotal > TURN_TOOL_CALL_CAP) {
this.lastLoopType = LoopType.CONSECUTIVE_IDENTICAL_TOOL_CALLS; // ← wrongThis fires when the total tool calls exceed 100, not when consecutive calls are identical. Telemetry will report "consecutive identical tool calls" when the real cause is "turn cap exceeded." This misleads debugging and analytics. Fix: add 2. Design note (non-blocking): New heuristic detectors are gated by The global duplicate and alternating pattern detectors live inside 3. Minor: value: { loopType: this.loopDetector.getLastLoopType()! },Works because Unrelated files (not reviewed in detail)The 7 React hook files, Chinese README, agent.ts, and enterPlanMode.ts are out of scope for this review — they should be in separate PRs as flagged in Stage 1. Test ResultsApplied the 5 core fix files to a worktree. Ran all loop-related tests: New circuit breaker tests (11 tests) all pass — covering turn cap, global duplicate, alternating pattern, disabledForSession interaction, and pattern reset after breaks. Real-scenario tmux testing isn't feasible for this change: triggering a model loop requires non-deterministic model behavior. Unit tests are the primary verification for internal loop detection logic. 中文说明代码审查独立方案(读 diff 前):对于 评估:核心方案合理,与我的独立方案一致。集成点正确(在门控之前),三个新检测器覆盖主要循环变体,测试覆盖全面。 发现的问题1. Bug(阻塞): 当总工具调用超过 100 时触发,但记录的是 2. 设计说明(非阻塞):新启发式检测器受 全局重复和交替模式检测器在 3. 次要: 能工作是因为 测试结果将 5 个核心修复文件应用到 worktree。所有循环相关测试通过:62 个测试通过,0 失败。 新的断路器测试(11 个)全部通过——覆盖轮次上限、全局重复、交替模式、disabledForSession 交互和中断后模式重置。 真实场景 tmux 测试对此改动不可行:触发模型循环需要非确定性模型行为。单元测试是内部循环检测逻辑的主要验证方式。 — Qwen Code · qwen3.7-max |
ReflectionThe core circuit breaker is well-built. The always-on safety layer before Going back to my independent proposal: the PR matches it closely. I would have done the same thing. The integration point is correct, the constants are reasonable (cap=100, global dup threshold=6, alternating cycles=3), and the reset logic properly clears all new state. But the PR as a whole has problems that block merge:
What to do:
The core logic is ready — it just needs to be in a focused PR. 中文说明反思核心断路器实现得很好。在 与我的独立方案对比:PR 实现高度一致。集成点正确,常量合理(上限=100,全局重复阈值=6,交替周期=3),重置逻辑正确清理所有新状态。 但 PR 整体有阻塞合并的问题:
建议:
核心逻辑已就绪——只需要放在一个聚焦的 PR 中。 — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
The core circuit breaker logic is solid — well-designed, well-tested, and addresses a real user problem. But the PR needs rework before merge:
- Split unrelated changes — 10/15 files don't belong here (React #185 fix, Chinese README, agent polling warning, enterPlanMode reveal). Please open separate PRs for each.
- Fix LoopType bug —
checkTurnToolCallCaplogsCONSECUTIVE_IDENTICAL_TOOL_CALLSbut should use a newTURN_TOOL_CALL_CAPtype. - Fill in the template — the reviewer test plan, motivation, and linked issues are blank.
Once scoped to just the 5 core files with the LoopType fix, this is ready to ship. 🙏
|
你们官方自己管吧,我没时间哦,我修复了自己用,免得消耗无效的token哦 |
|
Thanks for the fix, @aspnmy — and no worries at all. You found and solved a real problem (#5234), and the core circuit-breaker logic here is genuinely solid: the always-on safety layer before the Completely understand you don't want to spend more time on the rework — there's no obligation at all. We'll take it from here: the core logic is ready, so we'll pull it into a focused PR, apply the small |
|
Done — carried the core circuit breaker forward in #5279, with your commit cherry-picked so you stay credited as the author. It also includes the |
感谢理解,我只是为了自己不消耗token,至于增加的多余文件是向自己分支提交的自动代码 便于我在自己分支上查看,因为不习惯看英文,抛弃它就行 |
|
明白了——多余的文件(中文 README、news 条目)按你说的都没带进来。不过你那个 React #185 的修复本身是有价值的,已经单独提成 #5286,commit 保留你为作者。 补充一个发现供参考:这个 minified #185 在 React 19 里其实解码成 "Maximum update depth exceeded"(更新死循环),并不是"卸载后 setState"。真正的触发点是 再次感谢你把这些问题挖出来并提交上游 🙏 EnglishUnderstood — the extra files (Chinese README, news entry) are left out as you said. Your React #185 fix itself is valuable, so I've put it up as its own PR #5286 with your authorship preserved on the commit. One finding for context: in React 19 this minified #185 decodes to "Maximum update depth exceeded" (an update loop), not a setState-after-unmount. The real trigger is Thanks again for finding these and sending them upstream. 🙏 |
不清楚qwen-code自行修复自行维护的本地的技能,所以我还没时间去关注它是为什么关闭iss |
What this PR does
Why it's needed
Reviewer Test Plan
How to verify
Evidence (Before & After)
Tested on
Environment (optional)
Risk & Scope
Linked Issues
中文说明