Skip to content

[Feature]: ask_user request/response event pair and endpoint #5571

Open

Description

@analisaperlengkapan

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 (same QuestionInfo schema as the tool)
    and a typed request_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 distinct ask_user
    request event, not the status, is what distinguishes it from an action
    confirmation.
  • Concurrency. At most one pending ask_user request per conversation; a
    second call while one is pending is rejected with a corrective observation.
  • Timeout. A configurable timeout resolves the request as cancel so 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
    as cancel (the run never resumes into a dangling request).

Acceptance Criteria

  • A dedicated ask_user request/response event pair exists with a typed request_id, distinct from the tool-call id.
  • The endpoint accepts accept/decline/cancel; accept carries answers keyed by stable option id (with label for display).
  • The ask_user tool is rewired to resolve from the pair; a pending request reuses WAITING_FOR_CONFIRMATION and 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 as cancel.
  • The clients/typescript client 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

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 from respond_to_confirmation.
  • request_id typed as ULID/UUID; a single pending-request slot keyed by it.
  • Elicitation-aligned action enum (accept/decline/cancel).
  • Timeout as a server-side setting (not ConversationSettings); default disabled.
  • Regenerate the OpenAPI contract and the TypeScript client method.

Additional Context


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

  1. On the current Agent Server, attempt to have an ask_user request answered by a client that is not driving the conversation loop (e.g. Agent Canvas).
  2. Observe that no request/response event pair exists and no endpoint accepts a typed request_id with an accept/decline/cancel action, 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 questions and a typed request_id that is distinct from the tool-call id; a paired response event kind carries exactly one of accept (with answers), decline, or cancel, each echoing the request_id.
  • A dedicated Agent Server endpoint, separate from respond_to_confirmation, accepts an accept/decline/cancel payload; accept carries answers keyed by stable option id with the display label; the endpoint returns success on a valid response.
  • The ask_user tool resolves its observation from the pair (not from matching a send_message()); after a request is pending the conversation is in WAITING_FOR_CONFIRMATION; a second ask_user call while one is pending is rejected with a corrective observation and does not create a second pending request.
  • A response whose request_id does 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 cancel and the run unblocks; a request still pending at conversation close or restart resolves as cancel and 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 AgentServerFeatureRequirements gate with its minVersion, and an older backend surfaces the existing version-too-old error.
  • Automated tests cover accept, decline, and cancel; a stale/replayed request_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/ConversationSettings schema and golden fixtures are unchanged (the timeout is a server-side setting).

Activity

  1. added
    ready-for-dev
    on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementready-for-dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions