Skip to main content

Overview

The Agent interface defines the methods that all ACP-compliant agents must implement. These methods handle the lifecycle of the connection, session management, prompt processing, and cancellation.

Required Methods

initialize

Establishes the connection with a client and negotiates protocol capabilities.
string
required
The protocol version requested by the client
object
required
Capabilities advertised by the client (file system access, terminal support, etc.)
string
required
The protocol version the agent will use (should match the client’s version)
object
required
Capabilities advertised by the agent (session loading, modes, etc.)
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
See protocol docs: Initialization

Example

newSession

Creates a new conversation session with the agent.
string
Optional working directory for the session
MCPServerConfig[]
MCP servers to connect to for this session
string
required
A unique identifier for the new session
Mode[]
Optional list of available modes for this session
string
The initial mode for this session
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 throw an auth_required error if the agent requires authentication. See protocol docs: Session Setup

Example

authenticate

Authenticates the client using the specified authentication method.
string
required
The authentication method ID that was advertised during initialization
object
Optional credentials provided by the client
Called when the agent requires authentication before allowing session creation. After successful authentication, the client can proceed to create sessions with newSession without receiving an auth_required error. See protocol docs: Initialization

Example

prompt

Processes a user prompt within a session.
string
required
The session ID to process the prompt in
Message[]
required
The user messages with optional context (files, images, etc.)
StopReason
required
The reason the prompt turn ended: “end_turn”, “cancelled”, or “error”
This method handles the whole lifecycle of a prompt:
  • Receives user messages with optional context
  • Processes the prompt using language models
  • Reports language model content and tool calls to the client
  • Requests permission to run tools
  • Executes any requested tool calls
  • Returns when the turn is complete with a stop reason
See the Handling Prompts guide for detailed information. See protocol docs: Prompt Turn

Example

cancel

Cancels ongoing operations for a session.
string
required
The session ID to cancel operations for
This is a notification sent by the client to cancel an ongoing prompt turn. Upon receiving this notification, the agent SHOULD:
  • Stop all language model requests as soon as possible
  • Abort all tool call invocations in progress
  • Send any pending session/update notifications
  • Respond to the original session/prompt request with StopReason::Cancelled
See protocol docs: Cancellation

Example

Optional Methods

loadSession

Loads an existing session to resume a previous conversation.
string
required
The session ID to load
MCPServerConfig[]
MCP servers to connect to for this session
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

setSessionMode

Sets the operational mode for a session.
string
required
The session ID to update
string
required
The mode to switch to (must be one of the advertised modes)
Allows switching between different agent modes (e.g., “ask”, “architect”, “code”) that affect system prompts, tool availability, and permission behaviors. This method can be called at any time during a session, whether the agent is idle or actively generating a turn. See protocol docs: Session Modes

Unstable Methods

The following methods are marked as UNSTABLE and may be removed or changed at any point:
  • unstable_forkSession: Forks an existing session to create a new independent session
  • unstable_listSessions: Lists existing sessions from the agent
  • unstable_resumeSession: Resumes an existing session without returning previous messages
  • unstable_setSessionModel: Selects a model for a given session
These are experimental features not yet part of the official ACP specification.

Extension Methods

  • extMethod: Allows custom request handlers not part of the ACP specification
  • extNotification: Allows custom notification handlers not part of the ACP specification

Complete Example