Skip to content

ElicitationRequest

Base classes

Name Children Inherits
Request
aclientp.schema.base
Base request model.

â‹” Inheritance diagram

graph TD
  95970857280352["elicitation.ElicitationRequest"]
  95970858197488["base.Request"]
  95970862258240["base.AnnotatedObject"]
  95970862254416["base.Schema"]
  95970851503232["main.BaseModel"]
  125067848591872["builtins.object"]
  95970858197488 --> 95970857280352
  95970862258240 --> 95970858197488
  95970862254416 --> 95970862258240
  95970851503232 --> 95970862254416
  125067848591872 --> 95970851503232

🛈 DocStrings

Bases: Request

Request from the agent to elicit structured user input (elicitation/create).

The agent sends this to the client to request information from the user, either via a form or by directing them to a URL.

Mode and scope fields are flattened into the request on the wire:

  • mode: "form" carries requested_schema.
  • mode: "url" carries elicitation_id and url.
  • Session scope sets session_id (and optionally tool_call_id), request scope sets request_id (e.g. during auth before any session exists).
Source code in src/aclientp/schema/elicitation.py
class ElicitationRequest(Request):
    """Request from the agent to elicit structured user input (``elicitation/create``).

    The agent sends this to the client to request information from the user,
    either via a form or by directing them to a URL.

    Mode and scope fields are flattened into the request on the wire:

    - ``mode: "form"`` carries ``requested_schema``.
    - ``mode: "url"`` carries ``elicitation_id`` and ``url``.
    - Session scope sets ``session_id`` (and optionally ``tool_call_id``),
      request scope sets ``request_id`` (e.g. during auth before any session exists).
    """

    message: str
    """A human-readable message describing what input is needed."""

    mode: ElicitationModeType
    """The elicitation mode."""

    requested_schema: ElicitationSchema | None = None
    """Form mode: a JSON Schema describing the form fields to present to the user."""

    elicitation_id: str | None = None
    """URL mode: the unique identifier for this elicitation."""

    url: str | None = None
    """URL mode: the URL to direct the user to."""

    session_id: str | None = None
    """Session scope: the session this elicitation is tied to."""

    tool_call_id: str | None = None
    """Session scope: optional tool call within the session."""

    request_id: int | str | None = None
    """Request scope: the JSON-RPC request this elicitation is tied to."""

    @classmethod
    def form(
        cls,
        message: str,
        schema: ElicitationSchema,
        *,
        session_id: str | None = None,
        tool_call_id: str | None = None,
        request_id: int | str | None = None,
    ) -> Self:
        """Create a form-based elicitation request."""
        return cls(
            message=message,
            mode="form",
            requested_schema=schema,
            session_id=session_id,
            tool_call_id=tool_call_id,
            request_id=request_id,
        )

    @classmethod
    def url_based(
        cls,
        message: str,
        elicitation_id: str,
        url: str,
        *,
        session_id: str | None = None,
        tool_call_id: str | None = None,
        request_id: int | str | None = None,
    ) -> Self:
        """Create a URL-based elicitation request."""
        return cls(
            message=message,
            mode="url",
            elicitation_id=elicitation_id,
            url=url,
            session_id=session_id,
            tool_call_id=tool_call_id,
            request_id=request_id,
        )

elicitation_id class-attribute instance-attribute

elicitation_id: str | None = None

URL mode: the unique identifier for this elicitation.

message instance-attribute

message: str

A human-readable message describing what input is needed.

mode instance-attribute

The elicitation mode.

request_id class-attribute instance-attribute

request_id: int | str | None = None

Request scope: the JSON-RPC request this elicitation is tied to.

requested_schema class-attribute instance-attribute

requested_schema: ElicitationSchema | None = None

Form mode: a JSON Schema describing the form fields to present to the user.

session_id class-attribute instance-attribute

session_id: str | None = None

Session scope: the session this elicitation is tied to.

tool_call_id class-attribute instance-attribute

tool_call_id: str | None = None

Session scope: optional tool call within the session.

url class-attribute instance-attribute

url: str | None = None

URL mode: the URL to direct the user to.

form classmethod

form(
    message: str,
    schema: ElicitationSchema,
    *,
    session_id: str | None = None,
    tool_call_id: str | None = None,
    request_id: int | str | None = None,
) -> Self

Create a form-based elicitation request.

Source code in src/aclientp/schema/elicitation.py
@classmethod
def form(
    cls,
    message: str,
    schema: ElicitationSchema,
    *,
    session_id: str | None = None,
    tool_call_id: str | None = None,
    request_id: int | str | None = None,
) -> Self:
    """Create a form-based elicitation request."""
    return cls(
        message=message,
        mode="form",
        requested_schema=schema,
        session_id=session_id,
        tool_call_id=tool_call_id,
        request_id=request_id,
    )

url_based classmethod

url_based(
    message: str,
    elicitation_id: str,
    url: str,
    *,
    session_id: str | None = None,
    tool_call_id: str | None = None,
    request_id: int | str | None = None,
) -> Self

Create a URL-based elicitation request.

Source code in src/aclientp/schema/elicitation.py
@classmethod
def url_based(
    cls,
    message: str,
    elicitation_id: str,
    url: str,
    *,
    session_id: str | None = None,
    tool_call_id: str | None = None,
    request_id: int | str | None = None,
) -> Self:
    """Create a URL-based elicitation request."""
    return cls(
        message=message,
        mode="url",
        elicitation_id=elicitation_id,
        url=url,
        session_id=session_id,
        tool_call_id=tool_call_id,
        request_id=request_id,
    )

:fa-brands-github: Show source on GitHub