fix(auto-approve): escalate to manual keyboard when auto-Yes doesn't clear the prompt#142
Merged
Merged
Conversation
…clear the prompt `auto_approve=on` sent the `N. Yes` digit + Enter every poll but never verified the prompt actually cleared. A sub-agent (Agent/Task) WebFetch/WebSearch approval doesn't accept the top-level number hotkey, so the keystroke landed on a busy REPL, the prompt survived, and the poller re-fired the same auto-Yes forever — while shadowing the kb-mode keyboard / bg-status ❓, leaving the session wedged with no manual escape hatch (only a raw tmux Esc cleared it). Add cross-poll verification: each poll compares the prompt's signature (extract_interactive_content body+name, fallback to the option block) to the last one auto-approved. Same signature next poll ⇒ the keystroke did not clear it. After AUTO_APPROVE_MAX_ATTEMPTS (3) consecutive no-progress attempts on an identical prompt, stop auto-approving and return False so the caller surfaces the manual keyboard (active session) or the ❓ badge (background). Distinct prompts have distinct signatures ⇒ the counter resets, so normal one-shot approvals are untouched. _reconcile_no_ui_state pops the counter once the prompt clears. Tests: escalation after max, no false escalation across distinct prompts, counter reset on prompt clear. Existing debounce tests updated for the new _reconcile_no_ui_state(window_id) signature. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Problem
auto_approve=onsent theN. Yesdigit + Enter into the pane on every poll but never verified the prompt actually cleared. A sub-agent (Agent/Task) WebFetch/WebSearch approval doesn't accept the top-level number hotkey, so the keystroke landed on a busy REPL, the prompt survived, and the poller re-fired the same auto-Yes forever — while_maybe_auto_approvereturningTrueeach time shadowed the kb-mode keyboard / bg-status ❓. Net effect: the session wedged with no manual escape hatch (only a raw tmux Esc cleared it).Diagnosed on a live session (
region weather): aweb-researchersub-agent hung ~8 min on unreachable external web;Auto-approved opt=1spammed the log;stall_finalizefired; the user had to interrupt by hand.Fix (cross-poll verification + escalation)
extract_interactive_contentbody+name, fallback to the numbered option block) to the last one auto-approved. Same signature next poll ⇒ the keystroke did not clear it.AUTO_APPROVE_MAX_ATTEMPTS(3) consecutive no-progress attempts on an identical prompt, stop auto-approving and returnFalse→ the caller surfaces the manual keyboard (active session) or the ❓ badge (background)._reconcile_no_ui_statepops the counter once the prompt clears (newwindow_idparam).Log on give-up:
auto_approve giving up after N attempts (prompt not clearing) … — surfacing manual keyboard.Tests
test_auto_approve_escalates_after_max_attemptstest_auto_approve_distinct_prompts_never_escalatetest_auto_approve_counter_resets_when_prompt_clears_reconcile_no_ui_state(window_id)signature.pytest -k "status or interactive or kb_mode"→ 67 passed.ruffclean,pyright0 errors.🤖 Generated with Claude Code