CBox manager interactive stall detection and recovery
Problem
CBox sandbox sessions frequently stall at interactive prompts — effort level selectors, workspace trust dialogs, /pr-lite menus, permission confirmations, and AskUserQuestion multi-choice menus — that the Claude agent cannot dismiss on its own. When this happens, the sandbox appears hung to the manager with no indication of what it's waiting for. The manager has no automated way to detect that the stall is caused by an interactive prompt (vs. a compute-intensive operation), no policy for which prompts are safe to auto-dismiss, and no incident logging when stalls occur. This is one of the most frequent causes of sandbox workflow stalls and wasted manager cycles.
Context
Possible Solutions
Plan
Implementation Progress
InteractiveStallPatterndataclass intmux.py— pattern matcher for known interactive prompt signatures.detect_interactive_stall()function intmux.py— scans captured pane content against known patterns.dismiss_stall_pattern()function intmux.py— sends auto_dismiss_keys for a pattern (single source of truth for dismissal).check_interactive_stall()incli.py— captures pane, detects stall, auto-dismisses or escalates.cbox output --check-stallCLI flag — scriptable stall check (exits 2 if stalled).- Consolidated
_dismiss_interactive_prompts()to delegate to the pattern system (eliminates duplication). - 24 tests covering patterns, dismissal key sequences, false positives, and integration.
-
Workflow doc updates in
WORKFLOW.mdsection 3.1 with stall recovery runbook. -
Known interactive prompts (effort level, effort_level_alt, workspace trust, compact mode, AskUserQuestion menus, permission dialogs) are detected from pane capture.
- Safe prompts are auto-dismissed; unsafe ones return STALLED status with pattern info for incident logging.
cbox output --check-stall <name>provides CLI entry point for stall detection.- All new code is test-covered (24 new tests, 135 total).
- Workflow docs updated with stall recovery runbook.
Not delivered (deferred)
- Configurable stall timeout (
CBOX_INTERACTIVE_STALL_TIMEOUTenv var /--stall-timeoutflag) — deferred until the manager poll loop is implemented. The_resolve_timeoutgeneric is available for reuse.
Implementation notes
Architecture
InteractiveStallPatterndataclass intmux.py— name, signatures (AND-matched), auto_dismiss_keys, severity.INTERACTIVE_STALL_PATTERNS— ordered list; auto-dismissable patterns first to avoid false matches from broader patterns.detect_interactive_stall(content)— pure function, returns first matching pattern or None.dismiss_stall_pattern(session_name, pattern)— sends keys from auto_dismiss_keys, returns False for non-dismissable patterns.check_interactive_stall(session_name)— captures pane, detects pattern, auto-dismisses if possible, returns(InteractiveStallStatus, pattern).
Known patterns (6)
| Pattern | Signatures | Auto-dismiss | Severity |
|---|---|---|---|
| workspace_trust | "Quick safety check" + "Yes, I trust" | Select 1 + Enter | low |
| effort_level | "Effort in Opus" | Enter | low |
| effort_level_alt | "Use high effort" | Enter | low |
| compact_mode | "compact mode" + "❯ " | Enter | low |
| permission_dialog | "Allow?" | None | medium |
| ask_user_question | "\n? " + "❯ " + "\n " | None | high |
Files changed
libs/cbox/cbox/tmux.py—InteractiveStallPattern,INTERACTIVE_STALL_PATTERNS,detect_interactive_stall(),dismiss_stall_pattern(), refactored_dismiss_interactive_prompts()libs/cbox/cbox/cli.py—InteractiveStallStatus,check_interactive_stall(),_resolve_timeout(),cbox output --check-stalllibs/cbox/test_interactive_stall.py— 24 testslibs/cbox/skills/master-plan-cbox-manager/references/WORKFLOW.md— section 3.1 stall recovery runbooklibs/cbox/skills/master-plan-cbox-manager/SKILL.md— interactive stall detection section
Behavioral note
compact_mode auto-dismiss in the wait_for_prompt startup path is new behavior introduced by the consolidation of _dismiss_interactive_prompts into the pattern system.
- M1-INFRA-007 (review timeouts and stall detection) — builds on
StallStatusand_check_review_stall()patterns.
Review Feedback
- [ ] Review cleared