[FEATURE] Machine-readable AskUserQuestion state and no-answer semantics
Preflight Checklist
- [x] I have searched existing enhancement requests for "AskUserQuestion unattended marker timeout no-answer semantic answer" and did not find this targeted request.
- [x] This is a single feature request.
Problem Statement
Claude Code's interactive AskUserQuestion / question UI is useful when a human is present, but it currently creates unsafe ambiguity for unattended or multi-session operation.
When the harness asks a question during an autonomous run, operators and coordinating agents need to distinguish several states that currently blur together:
- The session is still working.
- The session is blocked on a question and needs a human.
- The question timed out or should be treated as "no answer".
- A coordinating agent has enough durable authority to answer semantically.
Without a machine-detectable question marker and no-answer path, downstream automation has to infer state from terminal text or keystrokes. That is fragile and can produce two bad incident classes:
- A "phantom answer" class, where generic text injection or recovery keystrokes accidentally select an option in an interactive question.
- An all-night freeze class, where an unattended run is blocked on a question but external coordination cannot reliably tell that the session is waiting for user input rather than working.
This is a harness/runtime concern rather than something project tooling can safely solve. In ADT we intentionally rejected an ADT-side keystroke "answer" implementation because it would rebuild the phantom-answer failure class.
Proposed Solution
Expose AskUserQuestion as a first-class, machine-readable interaction state with safe unattended semantics:
- A machine-detectable marker when a session is blocked on AskUserQuestion, including a stable question id, question text, option ids/labels, and whether an unattended answer is allowed.
- A timeout or operator-configurable policy that can resolve to an explicit "no answer" sentinel without choosing one of the visible options.
- A gated semantic answer channel that accepts a structured answer by question id, not raw keystrokes, and only when the harness has exposed that the question is answerable by automation.
- A way for external/session-management tooling to observe the state without screen-scraping the TUI.
The key safety property is that unattended tooling can report or park a question without accidentally selecting an answer, and any automated answer is bound to the specific question id/options the harness exposed.
Alternative Solutions
Current workarounds are all weaker:
- Terminal screen scraping can guess that a question is visible, but it is brittle across UI changes.
- Raw tmux/keyboard injection can answer the wrong prompt or select an option accidentally.
- Esc-cancel recovery can sometimes unwind a stuck session, but it is a recovery path, not a semantic answer API.
- Project-level coordination tools can record decisions, but they cannot prove the harness is currently asking a specific question with specific options.
Priority
High - Significant impact on productivity
Feature Category
Interactive mode (TUI)
Use Case Example
- A hub/coordinator starts several Claude Code workers overnight.
- One worker reaches an AskUserQuestion prompt about whether to proceed with a scoped operation.
- The coordinator queries session state and sees a structured
blocked_on_questionobject with question id, text, options, and timeout/no-answer policy. - If the coordinator lacks authority, it parks the decision and reports "worker blocked on question X" without selecting anything.
- If durable policy allows a semantic answer, the coordinator sends a structured answer for that question id.
- If no answer arrives before the timeout, the harness emits an explicit no-answer sentinel rather than silently choosing a default.
Additional Context
This request comes from the ADT hub control-plane work. The hub design explicitly treats a semantic AskUserQuestion answer API as upstream-only because project tooling cannot safely implement it with keystrokes.
Related design note in ADT: docs/dev/2026-06-24-hub-program-control-plane-plan.md, section 9 ("Hard / upstream").
3 Comments
This is a well-scoped request and the safety property you describe - automated answers bound to a specific question id, not raw keystrokes - is the right frame.
The phantom-answer failure class is exactly what makes naive tmux key-injection dangerous in multi-session setups. If your coordinator sends a keystroke to answer a question, but the session has moved on and a different interactive prompt is now visible, you've answered the wrong thing with no error signal. The only safe automated answer is one that is semantically bound to the specific question the harness exposed.
A few notes from building external session coordination for Claude Code:
The "blocked vs. working" state distinction is load-bearing for any unattended runner. Right now, if a scheduled session goes quiet, you cannot tell from outside whether it's still computing, waiting for user input, or has crashed. Machine-readable session state (including a stable
blocked_on_questionmarker) would make external coordination meaningfully safer - you could detect the block, park the run, and surface it for human review rather than letting it stall overnight or injecting a guess.Timeout-to-no-answer is safer than timeout-to-default. If a question sits unanswered past a deadline, the harness failing closed (parking the session, emitting a structured "no answer" event) is better than silently choosing whatever the cursor is on. Default selection under time pressure is how phantom answers happen.
The structured question id approach composes well with external tooling. If the harness exposes
{question_id, text, options, answerable_by_automation: bool}, an external coordinator can route the question to the right decision surface - human-required prompts go to a notification queue; automation-allowed prompts can be answered by policy - without the coordinator needing to parse TUI text or guess session state.Context: I've run into the state-detection problem repeatedly while building Claudeverse (claudeverse.ai), a session coordinator for multi-agent Claude Code workflows. The ambiguity between "working" and "blocked" is one of the harder operational problems at scale - happy to share more specifics if useful.
Thanks for the detailed writeup. Most of this is available today through hooks:
PreToolUsehook matched onAskUserQuestionreceives the full question set (question text, options, multi-select flag) as JSON on stdin, so your coordinator gets a machine-readable signal the moment a session wants to ask something.permissionDecision: "allow"plusupdatedInputwith ananswersmap, return"deny"with a reason to give Claude an explicit "no answer available" result, or (in-pmode) return"defer"so the process exits withstop_reason: "tool_deferred"and can be resumed later. Your own timeout policy can live inside that hook.Notificationhook fires when a session goes idle or is waiting on a prompt, for the "is it blocked?" case.Docs: https://code.claude.com/docs/en/hooks (see the AskUserQuestion and "defer" sections). If you still need something the hook path can't do, please open a focused follow-up.
🤖 Generated with Claude Code
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.