fix: feed back ExitPlanMode approval so CLI doesn't loop the plan#65
Merged
Conversation
ExitPlanMode is a requiresUserInteraction() tool — the CLI blocks waiting for an approval tool_result. The previous fix (PR #59) only surfaced the plan to the IM channel but never fed back an approval, so the next user reply re-entered the blocked CLI and the plan got re-emitted in a loop. Mirror the AskUserQuestion _pending_ask mechanism: when ExitPlanMode fires, surface plan + a Yes/No hint, set pending state with kind=exit_plan_mode, and return. On the next run(), parse the reply (yes/no prefix, CN + EN) and send the matching tool_result so the CLI can continue. Anything that doesn't match an approval word defaults to rejection with the reply as feedback, so a plan never runs without explicit approval. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
quick-sort
approved these changes
Jun 19, 2026
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
requiresUserInteraction()工具,CLI 阻塞等审批的 tool_result。PR fix: surface plan content to IM channel on ExitPlanMode #59 只 surface 了计划,没 feed back 审批,所以用户回复后 CLI 还卡着,计划被反复 emit_pending_ask机制:ExitPlanMode 触发时 surface 计划 + Yes/No 提示,设置kind=exit_plan_mode的 pending state,returnrun()按前缀解析 Yes/No(中英文都支持,longest-match 让 "不要用" 命中 "不要"),把对应 tool_result 发回去让 CLI 继续Test Plan
test_exit_plan_mode_surfaces_plan_with_hint— 计划 + 提示一起发,pending state 正确test_exit_plan_mode_without_plan_still_intercepts/test_exit_plan_mode_empty_plan_still_intercepts— 空 plan 也走拦截分支test_exit_plan_mode_resume_yes_approves— Yes 回复发送批准 tool_resulttest_exit_plan_mode_resume_no_with_feedback— No + 后续文字作为 feedbacktest_exit_plan_mode_resume_chinese_yes/test_exit_plan_mode_resume_chinese_no_with_feedback— 中文 好的/不要 也工作test_build_plan_approval_*— 单元测试覆盖 Yes/No/中文/ambiguous 各种回复Closes #64