fix: idle timeout 在等待用户交互时误触发重试#245
Merged
ErlichLiu merged 1 commit intoErlichLiu:mainfrom Apr 12, 2026
Merged
Conversation
AskUserQuestion、ExitPlanMode 审批、acceptEdits 权限确认等场景下, canUseTool 回调阻塞等待用户操作,期间 SDK 不产出新事件,导致 idle watcher 120s 后误判为 API 无响应并触发自动重试。用户还没回答完问题, 会话就被强制中断重启,答完后又需要重新回答重试产生的相同问题。 修复:添加 waitingForUserInput 标志,canUseTool 进入阻塞等待前设为 true(try/finally 保证清除)。idle watcher 检查时若标志为 true 则 重置计时器并跳过本轮检查,等用户操作完成后恢复正常超时检测。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
修复 idle timeout 在用户交互等待期间误触发自动重试的问题。当 Agent 发出 AskUserQuestion、ExitPlanMode 审批请求或 acceptEdits 权限确认时,
canUseTool回调会阻塞等待用户操作,期间 SDK 不产出新事件。idle watcher(120s 超时)无法区分"API 挂了"和"正在等用户回答",导致会话被错误中断重试,用户回答后还需重复回答来自重试的相同问题。Changes
apps/electron/src/main/lib/agent-orchestrator.ts— 添加waitingForUserInput标志:canUseTool中 AskUserQuestion、ExitPlanMode、acceptEdits 三个阻塞等待分支设置/清除标志(try/finally 保证异常路径也能清除)lastActivityAt并跳过本轮超时判断How to Test
Notes
waitingForUserInput也会短暂闪烁 true→false,但 idle watcher 30s 检查间隔远大于此窗口,不会产生误判