Merged
Conversation
Bash/Agent/TaskOutput/MCP 等工具执行期间 SDK 不产出新事件,idle watcher 120s 后误判为 API 无响应并触发自动重试,中断正在执行的工具。 通过 canUseTool 回调层检测长耗时工具(isLongRunningTool),在执行期间 设置 longRunningToolActive 标志抑制 idle timeout。收到 tool_result 或 turn 结束时清除标志,恢复正常超时检测。 与 waitingForUserInput 机制对称,共同覆盖所有「预期沉默」场景: - waitingForUserInput:等待用户操作(AskUser / 权限确认 / ExitPlanMode) - longRunningToolActive:等待工具执行结果(Bash / MCP / Agent / TaskOutput) 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.
Summary
canUseTool回调层检测长耗时工具(isLongRunningTool),执行期间设置longRunningToolActive标志抑制 idle timeout,收到tool_result或 turn 结束时清除waitingForUserInput机制对称,共同覆盖所有「预期沉默」场景Design
在
canUseTool回调层(而非消息内容解析层)检测工具类型,仅对确实可能长时间执行的工具抑制 idle timeout:清除时机:
tool_resultuser 消息 → 工具执行完毕result消息 → turn 结束兜底清除Test plan
IDLE_TIMEOUT_MS改为10_000,执行sleep 30,验证不被中断🤖 Generated with Claude Code