Module 31: Elicitation
An agent asks the user for structured input in the middle of a prompt: a form the client renders, and the user accepts, declines, or cancels.What You’ll Learn
- Sending an elicitation request from an agent with
createElicitation - Building a form schema: text, single-select, multi-select, boolean, and integer fields
- Handling accept, decline, and cancel responses in the agent
- Advertising elicitation support and answering requests on the client
The Code
Agent: ask for a form mid-prompt
Elicitation is an agent-to-client request, so the prompt handler needs a reference to the agent. The async API makes the request-then-continue flow aflatMap:
Client: advertise support and answer
The client declares elicitation support in its capabilities and registers a handler. A real client shows the form to the user; the demo fills it in automatically:Form Field Types
Responses
The agent must handle all three. A prompt that depends on the form still has to end its turn when the user declines or cancels.
Elicitation was added in SDK 0.12.0 as an unstable protocol element, marked
@UnstableAcpApi. It may change in a minor release.