Skip to content

fix(auto-approve): escalate to manual keyboard when auto-Yes doesn't clear the prompt#142

Merged
Time4Mind merged 1 commit into
mainfrom
fix/auto-approve-escalation
Jul 6, 2026
Merged

fix(auto-approve): escalate to manual keyboard when auto-Yes doesn't clear the prompt#142
Time4Mind merged 1 commit into
mainfrom
fix/auto-approve-escalation

Conversation

@Time4Mind

Copy link
Copy Markdown
Owner

Problem

auto_approve=on sent the N. Yes digit + 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_approve returning True each 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): a web-researcher sub-agent hung ~8 min on unreachable external web; Auto-approved opt=1 spammed the log; stall_finalize fired; the user had to interrupt by hand.

Fix (cross-poll verification + escalation)

  • Each poll compares the prompt's signature (extract_interactive_content body+name, fallback to the numbered 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 → the caller surfaces the manual keyboard (active session) or the ❓ badge (background).
  • Distinct prompts (different domain/file) have distinct signatures ⇒ the counter resets, so normal one-shot approvals are untouched.
  • _reconcile_no_ui_state pops the counter once the prompt clears (new window_id param).

Log on give-up: auto_approve giving up after N attempts (prompt not clearing) … — surfacing manual keyboard.

Tests

  • test_auto_approve_escalates_after_max_attempts
  • test_auto_approve_distinct_prompts_never_escalate
  • test_auto_approve_counter_resets_when_prompt_clears
  • Existing kb-mode debounce tests updated for the new _reconcile_no_ui_state(window_id) signature.

pytest -k "status or interactive or kb_mode" → 67 passed. ruff clean, pyright 0 errors.

🤖 Generated with Claude Code

…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>
@Time4Mind Time4Mind merged commit 7b27e4e into main Jul 6, 2026
4 checks passed
@Time4Mind Time4Mind deleted the fix/auto-approve-escalation branch July 6, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant