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
The ask_user tool (companion issue #5565) lets the agent ask structured questions,
and in that slice the answer arrives through the interim confirmation pause/resume
path (a send_message() message matched to the single pending request). That interim
path cannot deterministically match an answer to exactly one pending request for a
client that is not driving the conversation loop (Agent Canvas). This issue is the
canonical transport: a typed request id, and a distinct action so "answered",
"declined", and "dismissed" stay distinguishable.
Relationship to #5565 (resolved). #5566 rewires the tool to resolve from the
new request/response pair — the tool's answer path is owned here. #5565 ships the
tool + QuestionInfo schema (standalone, via the interim pause/resume), so #5565
does not block on #5566; #5566 depends on #5565's QuestionInfo/tool and
replaces the interim send_message() matching with the typed pair. QuestionInfo
and the pause/resume run shape are in scope here only as the rewiring target (not
re-designed).
The existing confirmation endpoint
(POST /api/conversations/{id}/events/respond_to_confirmation with
ConfirmationResponseRequest {accept, reason}) is a boolean "approve this action"
and cannot carry an option id — which is also why #5480 is blocked. Overloading it
would mix two lifecycles and leave no room for a typed request id.
Desired Behavior
A dedicated ask_user request/response event pair plus an endpoint, designed to
the MCP-elicitation three-action shape so SDK elicitation can be layered on later.
- A request event carries the
questions(sameQuestionInfoschema as the tool)
and a typedrequest_id(ULID/UUID, distinct from the tool-call id). - A response event carries one of:
{ "action": "accept", "request_id": "",
"answers": { "": { "option_id": "jwt", "label": "JWT bearer tokens" } } }
{ "action": "decline", "request_id": "" }
{ "action": "cancel", "request_id": "" }
- A stale or replayed answer is rejected unless it matches exactly one pending
request; the tool observation reflects the resolution.
Pending-request lifecycle and timeout (resolved).
- Status. A pending request reuses the existing
WAITING_FOR_CONFIRMATION
status (no new serialized status value in this issue); the distinctask_user
request event, not the status, is what distinguishes it from an action
confirmation. - Concurrency. At most one pending
ask_userrequest per conversation; a
second call while one is pending is rejected with a corrective observation. - Timeout. A configurable timeout resolves the request as
cancelso the
loop always unblocks. It lives in a server-side setting (not
ConversationSettings), so this issue does not touch the public persisted
settings schema or its migration/golden-fixture machinery; the default is
disabled (wait indefinitely, matching confirmation mode), with an optional
per-request override carried on the request event. - Close / restart. A pending request at conversation close or restart resolves
ascancel(the run never resumes into a dangling request).
Acceptance Criteria
- A dedicated
ask_userrequest/response event pair exists with a typedrequest_id, distinct from the tool-call id. - The endpoint accepts
accept/decline/cancel;acceptcarries answers keyed by stable option id (with label for display). - The
ask_usertool is rewired to resolve from the pair; a pending request reusesWAITING_FOR_CONFIRMATIONand at most one request is pending per conversation. - A stale or replayed answer is rejected and does not resolve a different pending request.
- A configurable timeout (server-side setting, default disabled) resolves an unanswered request as
cancel; a pending request at close/restart resolves ascancel. - The
clients/typescriptclient exposes a method to read the request and post a response. - The OpenAPI/typed-client surface is updated, and any new minimum Agent Server version is reflected in the compatibility field.
- Tests cover accept/decline/cancel, stale/replayed
request_id, the one-pending-request rule, and the timeout/close paths.
Alternatives Considered
- Generalize
respond_to_confirmationto carry an answer payload. Rejected: mixes
the boolean approval lifecycle with question answering and leaves no typed
request id (see [Feature]: Let ACP clients answer permission requests instead of always selecting the first option #5480). - Model it as MCP elicitation only. Elicitation is currently a decline-only stub in
the ACP bridge, so it is not yet a usable primitive; adopt its response shape now,
layer elicitation later.
Priority / Severity
High - Significant impact on productivity
Estimated Scope
Large - Significant feature requiring architecture changes
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)
- New request/response event classes alongside the existing confirmation events in
event_router.py; a new endpoint separate fromrespond_to_confirmation. request_idtyped as ULID/UUID; a single pending-request slot keyed by it.- Elicitation-aligned
actionenum (accept/decline/cancel). - Timeout as a server-side setting (not
ConversationSettings); default disabled. - Regenerate the OpenAPI contract and the TypeScript client method.
Additional Context
- Companion tool issue: [Feature]: ask_user tool (structured questions, answers as a user message) #5565 (
ask_userSDK tool). [Feature]: Dedicated ask_user request/response event pair and endpoint #5566 rewires its answer path
to this pair. - Follow-up consumer: the Agent Canvas dialog in
OpenHands/OpenHands(renders the
questions, posts the answers). - Prior design and full prior art: closed [Feature]: A structured "ask the user" tool — multiple-choice questions mid-task, with a free-text escape hatch #5506. Related: [Feature]: Let ACP clients answer permission requests instead of always selecting the first option #5480.
- MCP Elicitation (spec 2025-06-18):
https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation
OpenHands AI triage
The following comments and acceptance criteria were added by the OpenHands AI agent.
Triage
Scope is bounded to this repository, which owns the Python SDK, Agent Server, and the canonical REST/WebSocket API; the OpenAPI contract and clients/typescript/ mirror live here too, so this is the correct repo. ask_user is a pause/resume tool, not a blocking call: run()/arun() hold the conversation state lock across agent.step(), so the answer must resume the run. The closest existing implementation to mirror is the confirmation flow -- respond_to_confirmation in openhands-agent-server/openhands/agent_server/event_router.py, ConfirmationResponseRequest {accept, reason} in models.py, EventService.respond_to_confirmation/reject_pending_actions in event_service.py, and ConversationExecutionStatus.WAITING_FOR_CONFIRMATION in openhands-sdk/openhands/sdk/conversation/state.py -- while the new endpoint must stay separate so a typed request_id and answer payload can be carried. The TypeScript feature-gate pattern (a requirement with a minVersion in clients/typescript/src/client/agent-server-compatibility.ts) is the mechanism to reuse for any new minimum Agent Server version. The wire shapes are already fixed in the issue (MCP-elicitation-shaped accept/decline/cancel, a typed request_id distinct from the tool-call id, answers keyed by stable option id with a display label) and align with build order: Python backend first, then OpenAPI, then clients/typescript/.
Non-goals (explicit): designing SDK MCP elicitation itself (the shape is adopted now, elicitation is layered later); the ask_user tool and QuestionInfo schema (owned by #5570); Agent Canvas dialog UI and frontend state (owned by OpenHands/OpenHands); and any change to the persisted AgentSettings/ConversationSettings schema or its migration/golden-fixture machinery (the timeout is a server-side setting).
Dependency: this issue depends on the ask_user tool and QuestionInfo schema shipped by #5570 (currently ready-for-dev); without them there is nothing to rewire. The pair/endpoint can be built in parallel against the agreed schema, but the rewiring criterion completes only once #5570 lands.
Actual Behavior
There is no ask_user request event, no response event, and no endpoint for it. No typed request_id or accept/decline/cancel action exists on the Agent Server. Answers can only currently be carried by the interim send_message()/MessageEvent(source="user") path or by the boolean respond_to_confirmation endpoint, which carries {accept, reason} and cannot express a selected option id. Verified against master: ask_user/QuestionInfo do not exist yet, and event_router.py exposes only respond_to_confirmation.
Steps to Reproduce
- On the current Agent Server, attempt to have an
ask_userrequest answered by a client that is not driving the conversation loop (e.g. Agent Canvas). - Observe that no request/response event pair exists and no endpoint accepts a typed
request_idwith anaccept/decline/cancelaction, so an answer cannot be deterministically matched to exactly one pending request.
Desired Behavior
A dedicated ask_user request event (carrying the questions and a typed request_id distinct from the tool-call id) and a paired response event, plus an endpoint that accepts accept/decline/cancel. accept carries answers keyed by stable option id with a display label; a stale or replayed answer is rejected unless it matches exactly one pending request. Pending requests reuse WAITING_FOR_CONFIRMATION, at most one is pending per conversation, a server-side configurable timeout (default disabled) resolves an unanswered request as cancel, and a pending request at close/restart resolves as cancel. The ask_user tool is rewired to resolve from the pair, clients/typescript/ exposes read-request/post-response, and the OpenAPI/typed-client surface is updated with any new minimum Agent Server version reflected in the compatibility field.
Acceptance Criteria
- A request event kind carries the
questionsand a typedrequest_idthat is distinct from the tool-call id; a paired response event kind carries exactly one ofaccept(withanswers),decline, orcancel, each echoing therequest_id. - A dedicated Agent Server endpoint, separate from
respond_to_confirmation, accepts anaccept/decline/cancelpayload;acceptcarriesanswerskeyed by stable option id with the display label; the endpoint returns success on a valid response. - The
ask_usertool resolves its observation from the pair (not from matching asend_message()); after a request is pending the conversation is inWAITING_FOR_CONFIRMATION; a secondask_usercall while one is pending is rejected with a corrective observation and does not create a second pending request. - A response whose
request_iddoes not match the single pending request is rejected with a non-resolving error/observation and leaves the pending request intact; a replayed response for an already-resolved request is likewise rejected. - With the server-side timeout disabled (default), an unanswered request waits indefinitely; with a timeout configured, an expired request resolves as
canceland the run unblocks; a request still pending at conversation close or restart resolves ascanceland the run does not resume into a dangling request. -
clients/typescript/exposes a method to read the request event and a method to post a response, and the generated OpenAPI/typed-client surface includes the new event kinds and endpoint. - If the feature requires a newer Agent Server, the minimum version is enforced through the existing TypeScript
AgentServerFeatureRequirementsgate with itsminVersion, and an older backend surfaces the existing version-too-old error. - Automated tests cover
accept,decline, andcancel; a stale/replayedrequest_id; the one-pending-request rule; and the timeout and close/restart resolution paths. - Serialized-event and settings compatibility is preserved: existing event-kind consumers and the persisted
AgentSettings/ConversationSettingsschema and golden fixtures are unchanged (the timeout is a server-side setting).
Activity