pub enum ClientRequest {
InitializeRequest(InitializeRequest),
AuthenticateRequest(AuthenticateRequest),
NewSessionRequest(NewSessionRequest),
LoadSessionRequest(LoadSessionRequest),
SetSessionModeRequest(SetSessionModeRequest),
PromptRequest(PromptRequest),
ExtMethodRequest(ExtRequest),
}Expand description
All possible requests that a client can send to an agent.
This enum is used internally for routing RPC requests. You typically won’t need
to use this directly - instead, use the methods on the [Agent] trait.
This enum encompasses all method calls from client to agent.
Variants§
InitializeRequest(InitializeRequest)
Establishes the connection with a client and negotiates protocol capabilities.
This method is called once at the beginning of the connection to:
- Negotiate the protocol version to use
- Exchange capability information between client and agent
- Determine available authentication methods
The agent should respond with its supported protocol version and capabilities.
See protocol docs: Initialization
AuthenticateRequest(AuthenticateRequest)
Authenticates the client using the specified authentication method.
Called when the agent requires authentication before allowing session creation. The client provides the authentication method ID that was advertised during initialization.
After successful authentication, the client can proceed to create sessions with
new_session without receiving an auth_required error.
See protocol docs: Initialization
NewSessionRequest(NewSessionRequest)
Creates a new conversation session with the agent.
Sessions represent independent conversation contexts with their own history and state.
The agent should:
- Create a new session context
- Connect to any specified MCP servers
- Return a unique session ID for future requests
May return an auth_required error if the agent requires authentication.
See protocol docs: Session Setup
LoadSessionRequest(LoadSessionRequest)
Loads an existing session to resume a previous conversation.
This method is only available if the agent advertises the loadSession capability.
The agent should:
- Restore the session context and conversation history
- Connect to the specified MCP servers
- Stream the entire conversation history back to the client via notifications
See protocol docs: Loading Sessions
SetSessionModeRequest(SetSessionModeRequest)
Sets the current mode for a session.
Allows switching between different agent modes (e.g., “ask”, “architect”, “code”) that affect system prompts, tool availability, and permission behaviors.
The mode must be one of the modes advertised in availableModes during session
creation or loading. Agents may also change modes autonomously and notify the
client via current_mode_update notifications.
This method can be called at any time during a session, whether the Agent is idle or actively generating a response.
See protocol docs: Session Modes
PromptRequest(PromptRequest)
Processes a user prompt within a session.
This method handles the whole lifecycle of a prompt:
- Receives user messages with optional context (files, images, etc.)
- Processes the prompt using language models
- Reports language model content and tool calls to the Clients
- Requests permission to run tools
- Executes any requested tool calls
- Returns when the turn is complete with a stop reason
See protocol docs: Prompt Turn
ExtMethodRequest(ExtRequest)
Handles extension method requests from the client.
Extension methods provide a way to add custom functionality while maintaining protocol compatibility.
See protocol docs: Extensibility
Trait Implementations§
Source§impl Clone for ClientRequest
impl Clone for ClientRequest
Source§fn clone(&self) -> ClientRequest
fn clone(&self) -> ClientRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClientRequest
impl Debug for ClientRequest
Source§impl<'de> Deserialize<'de> for ClientRequest
impl<'de> Deserialize<'de> for ClientRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for ClientRequest
impl JsonSchema for ClientRequest
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more