Repository navigation
Description
Is there an existing feature request for this?
- I have searched existing issues and feature requests, and this is not a duplicate.
Problem or Use Case
When the agent hits genuine ambiguity mid-task it has no structured way to ask the
user. It either guesses — risking wasted work — or drops the question into a chat
message, which does not pause execution and offers no clear choices. This is the
top gap in the Claude Code parity tracker (#2055).
Concrete cases:
- Architecture decisions the code does not encode. "Add authentication to
this API" — session, JWT, or OAuth? Each cascades into schema, middleware, and
frontend. Today the agent picks one and hopes. - Destructive migrations with several valid paths. "Migrate class components
to hooks" — all at once, incrementally by directory, or simple-first? - Product decisions. "Create a user settings page" —
/settingsvs
/accountvs/preferences, which sections? These cannot be inferred.
Desired Behavior
A first-class SDK tool, ask_user, that lets the agent pause mid-task and ask one
or more structured questions in a single call. Each question has 2–4 labelled
options (each with a description), single- or multi-select, and an
always-available "Other" free-text escape hatch. The call ends the current run
at a waiting status; the user's answer resumes the run and becomes the tool
observation (the same pause/resume shape as confirmation mode — not a
fire-and-forget call).
This issue is the first, self-contained slice and adds no new Agent Server
endpoint or event type: the answer arrives through the existing
send_message() path as a MessageEvent(source="user"), which the SDK matches to
the single pending ask_user request and converts into the tool observation on
resume. The dedicated request/response event pair + endpoint is split into a
follow-up issue (#5566).
Mechanism (resolved — answers the triage questions)
The earlier draft said answers arrive "through the UserMessageEvent path". That
type does not exist (user messages are MessageEvent(source="user")), and a tool
cannot simply block on the run-loop thread, which holds the conversation state
FIFOLock across agent.step(). The concrete, deadlock-free mechanism is option
(b) — the confirmation-style pause/resume, not a blocking tool:
- Where the answer enters (Q1). The
ask_usertool validates its arguments,
records one pending request (a generatedrequest_idplus the questions) in
the conversation state, and the run ends atWAITING_FOR_CONFIRMATION(the
existing "run yielded control to the user, resume on input" status — reused to
avoid a new serialized status value in this slice). The answering client calls
send_message()with the structured answer; the SDK detects the single pending
ask_userrequest, converts thatMessageEvent(source="user")into the tool's
observation instead of a normal user turn, and the client resumes the run.
So the answer is a user message — the wording "not as a separate later
message" is dropped; the distinction is that it is consumed as the tool result
for the pending call, not appended as an unrelated turn. - Parsing / validation contract (Q2). Because there is no dedicated transport
in this slice, the structured answer is carried in the user message and matched
by therequest_idrecorded in the pending request. The SDK validates: the
message parses as an answer object, itsrequest_idmatches the one pending
request, and each answer references a question/option that exists. A malformed,
mis-keyed, or stale answer produces a corrective observation ("no pending
ask_user request" / "unrecognized option id …") and does not resolve the call.
The typedrequest_idand the dedicated request/response pair land in [Feature]: Dedicated ask_user request/response event pair and endpoint #5566. - Non-interactive runs (Q3). There is no
interactivecapability flag, and
tool availability is process-global, so this slice cannot define a flag. The
non-interactive criterion is deferred: for now the tool simply is not offered
in headless/eval runs by not registering it there (a follow-up adds the
capability flag and the prompt section; [Feature]: Dedicated ask_user request/response event pair and endpoint #5566 owns the timeout →cancelpath
so a pending request always unblocks).
Why this cannot be a Canvas-only / client-tool feature
Agent Canvas already registers client tools via ClientToolSpec
(openhands/sdk/tool/client_tool.py), used today for canvas_ui_control and
launch_child_conversation. It is tempting to implement the dialog there — but
client tools are fire-and-forget and cannot carry a result back:
ClientToolExecutor.__call__ returns an inline
ClientToolObservation.from_text(text="Tool call dispatched to client."); the real
execution happens client-side and the agent loop continues as if the tool had
completed. ClientToolSpec is {name, description, parameters, annotations} with
no representation of a return value. So a client-tool dialog can show the
question, but the choice has no channel back as the tool result.
Conclusion: the primitive belongs in the SDK. Canvas then consumes it.
Acceptance Criteria
-
ask_useris a first-class SDK tool whose action carries
questions: list[QuestionInfo], each with aheader(short label), 2–4
options(stableid,label,description), and amultiSelectflag. - The call ends the run at
WAITING_FOR_CONFIRMATIONwith one pendingask_user
request recorded; the user's answer resumes the run and becomes the tool
observation (consumed as the tool result, not appended as an unrelated turn). - The answering contract keys answers by a stable option id (the
label
is carried alongside for display), matched to the pending request by its
request_id; the free-text "Other" value is carried with a sentinel/null
option id. -
decline(user said stop asking) andcancel(dismissed) are
distinguishable from an answer in the observation. - Invalid calls (0 questions, >4 options, missing labels, duplicate
ids/labels) return a corrective observation so the agent can fix the call,
not a crash. - A malformed, mis-keyed, or stale answer (no matching pending request, or an
unknown option id) produces a corrective observation and does not resolve the
call. - Non-interactive handling is deferred in this slice: the tool is simply
not registered in headless/eval runs (theinteractivecapability flag and
the timeout →cancelpath land in [Feature]: Dedicated ask_user request/response event pair and endpoint #5566). - Unit tests cover the schema validation, the pause/resume answer path, and the
accept/decline/cancel+ free-text cases.
Alternatives Considered
- Implement it purely in Agent Canvas as a client tool. Rejected: client tools
are fire-and-forget and cannot return a result (see above). - Prompt the agent to ask in prose. Today's behaviour: does not block, offers
no structured choices. - MCP Elicitation only. Elicitation is server-initiated; this feature is
agent-initiated. Adopt its three-action shape later, but do not block this slice
on it (elicitation is currently a decline-only stub in the ACP bridge).
Priority / Severity
High - Significant impact on productivity
Estimated Scope
Medium - New feature with moderate complexity
Feature Area
- Agent API / Core functionality
- Tools / Tool system
- Skills / Plugins
- Agent Server
- Workspace management
- Configuration / Settings
- Examples / Templates
- Documentation
- Testing / Development tools
- Performance / Optimization
- Integrations (GitHub, APIs, etc.)
- Other
Technical Implementation Ideas (Optional)
- Tool name
ask_user(lowercase snake_case, matchingfinish,task_tracker,
ask_oracle,vision_inspect). - Action:
questions: list[QuestionInfo].QuestionInfo:
{question, header (<=12 chars), options: list[{id, label, description}] (2–4), multiSelect: bool}. - Observation: the answers keyed by question, each answer
{option_id|null, label}; plusactioninaccept/decline/cancel. - The agent loop must treat this call as a pause, not the fire-and-forget
client-tool path: record the pending request, end the run at
WAITING_FOR_CONFIRMATION, and convert the matchingsend_message()answer into
the tool observation on resume. - Server-side validation rejects malformed calls with a corrective observation.
Additional Context
Split and follow-up
- This issue (PR 1): the SDK tool + action/observation, using the confirmation
pause/resume shape (the answer arrives viasend_message()as a
MessageEvent(source="user")and is converted to the tool observation). No new
endpoint, no new event type. - Follow-up (PR 2, issue [Feature]: Dedicated ask_user request/response event pair and endpoint #5566): a dedicated
ask_userrequest/response
event pair + endpoint on the Agent Server, elicitation-aligned
(accept/decline/cancel), plus a typedrequest_idso a stale or replayed
answer matches exactly one pending request; and theclients/typescriptmethod.
This is what lets a non-loop client (Agent Canvas) answer deterministically. - Follow-up (PR 3,
OpenHands/OpenHands): the Agent Canvas dialog that renders
the questions and returns the answers.
Prior art / standards
- Claude Code
AskUserQuestion— the reference.
questions[]{question, header(<=12), options[2-4]{label, description}, multiSelect};
"Other" always available. https://code.claude.com/docs/en/agent-sdk/user-input - MCP Elicitation (spec 2025-06-18) —
elicitation/createwithmessage+
requestedSchema; responsesaccept/decline/cancel.
https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation - Other implementations: LangChain deepagents
ask_user(LangGraph interrupts);
Spring AIAskUserQuestionTool; [Feature]: Use Claude Code's native AskUserQuestion tool instead of numbered-option prompts github/spec-kit#2181; Use AskUserQuestion tool on Claude Code for structured user input obra/superpowers#745.
Prior requests (this issue revives them)
- [Tracking] Tools: Missing tool types & dynamic discovery gaps #2041 — "[Tracking] Tools: Missing tool types & dynamic discovery gaps" (closed
not_planned, stale, 2026-07-26). Part of tracker Feature Parity: Bridge Gap with Claude Code Capabilities #2055. - [Feature]: QuestionTool -- let the agent ask the user structured questions mid-task #2697 — "[Feature]: QuestionTool -- let the agent ask the user structured
questions mid-task" (closednot_planned, stale, 2026-09-25). - Historical CLI-only attempts: OpenHands/OpenHands #9392 (issue), #9758 / #9824
(PRs, unmerged). - Related open: [Feature]: Let ACP clients answer permission requests instead of always selecting the first option #5480 (ACP permission requests always auto-select
options[0]; same
"confirmation API is accept/reject only" root cause).
Resolved decisions (revised for this slice)
- Transport: the dedicated
ask_userrequest/response pair is a follow-up;
this slice uses the confirmation pause/resume shape — record a pending request,
end the run atWAITING_FOR_CONFIRMATION, and convert the matching
send_message()answer (MessageEvent(source="user")) into the tool observation. - Scope: split — PR 1 (this issue, tool only), PR 2 (issue [Feature]: Dedicated ask_user request/response event pair and endpoint #5566: transport +
clients/typescript), PR 3 (Canvas dialog). - Answering contract: stable option id (+ label for display); free-text via
sentinel option id; distinctdecline/cancel; arequest_idis recorded now
(to match the answer to the pending request) and formalized as a typed field on
the dedicated pair in [Feature]: Dedicated ask_user request/response event pair and endpoint #5566. - Interactive vs non-interactive: deferred in this slice — the tool is not
registered in headless/eval runs. Theinteractivecapability flag and the
timeout →cancelpath are owned by [Feature]: Dedicated ask_user request/response event pair and endpoint #5566 (no such flag exists onmain, and
tool availability is process-global). - Tool name:
ask_user.
Full prior art and the original design are on the closed #5506.
Activity
all-hands-bot commentedon Oct 7, 2026
The following comments were added by the OpenHands AI agent.
Decision needed
This is the bounded first slice of the
ask_userfeature, and the split from the transport (deferred to #5566) is sound. I verified the surrounding code onmainto finalize it, but the load-bearing mechanism for this slice is still described two contradictory ways, soready-for-devis withheld until it is settled.What I confirmed in the repository:
UserMessageEventtype. User messages areMessageEvent(source="user"), emitted byLocalConversation.send_message().run()/arun()hold the conversation stateFIFOLockacrossagent.step(), sotool(action, conversation)executes while that lock is held; a tool called as the sole tool call in a batch runs on the run loop's thread. A tool that blocks waiting for a user message has no defined, deadlock-free unblock path. The only existing "wait for the user" primitive — confirmation mode — ends the run (statusWAITING_FOR_CONFIRMATION) instead of continuing to the answer within the step, and no tool returns a value to the agent this way.interactivecapability flag anywhere in the SDK or Agent Server, and tool availability (list_usable_tools()) is process-global, not per-conversation.The unresolved questions needed to set scope and acceptance criteria:
Within this SDK-only slice, exactly where does the answer enter the agent so the call unblocks and the answers become the tool observation? Target flows:
send_message()provides the answer — if so, which thread must the tool run on (the run-loop thread holds the state lock, and a worker thread must not block thesend_message()the answering client needs), and how does the run loop's state lock get released for a blocking tool?; orPlease remove the "not as a separate later message" wording if the answer necessarily arrives as a user message.
What is the concrete parsing/validation contract for the answer, given there is no
UserMessageEvent? The issue specifies duplicate ids/labels are rejected, but reusingsend_messageoffers no schema and no correlation to a specific pendingask_usercall. How is a malformed or stale answer detected and converted to a corrective observation, given there is norequest_idin this slice (it is deferred to [Feature]: Dedicated ask_user request/response event pair and endpoint #5566)?For the "non-interactive" criterion in this slice: what is the source of the
interactivecapability in an SDK-only change, given the flag does not exist? Is adding a capability field plus a system-prompt section in scope here, or should this criterion be deferred to a follow-up?Once these are answered in the issue body, the triage will define the observable criteria (blocking unblock path, answer delivery,
accept/decline/cancel+ free-text the agent consumes, malformed-call corrective observation, non-interactive behavior) and re-evaluate readiness. Note the boolean at the top of the issue ("answers are delivered through the existingUserMessageEventpath") also needs to name the real event type.analisaperlengkapan commentedon Oct 7, 2026
The three questions are now resolved in the body (new "Mechanism (resolved)" section; Acceptance Criteria and Resolved decisions updated).
ask_userrecords one pending request and the run ends atWAITING_FOR_CONFIRMATION; the answering client callssend_message(), and the SDK converts thatMessageEvent(source="user")into the tool observation, then the client resumes. The answer is a user message, so the "not as a separate later message" wording is dropped. (The "UserMessageEventpath" wording was wrong — that type does not exist.)request_id; malformed/mis-keyed/stale answers produce a corrective observation and do not resolve the call. The typed field on a dedicated pair lands in [Feature]: Dedicated ask_user request/response event pair and endpoint #5566.interactiveflag exists; tool availability is process-global). The tool is simply not registered in headless/eval runs; the flag and the timeout →cancelpath are owned by [Feature]: Dedicated ask_user request/response event pair and endpoint #5566.This comment was created by an AI agent (OpenHands) on behalf of @analisaperlengkapan.
analisaperlengkapan commentedon Oct 7, 2026
Closing to refile through the web issue form.
The triage automation marked this issue
decision_neededand, per its owncontract, is only invoked when an issue is opened (or via a label/mention event).
Resolving the questions by editing the body and replying in-thread does not
re-invoke it, so it has not re-evaluated the issue — it is still without
ready-for-devafter the decisions were recorded. Refiling through the form so thetriage automation runs on creation.
The scope and the recorded decisions are unchanged; they are carried verbatim into
the refile.
This comment was created by an AI agent (OpenHands) on behalf of @analisaperlengkapan.