Skip to main content
Sessions are independent conversation contexts in ACP. Each session maintains its own history, state, and configuration, allowing multiple parallel conversations with an agent.

What are Sessions?

A session represents a distinct conversation between a user and an agent. Sessions provide:
  • Independent Context - Each session has its own conversation history
  • Isolated State - Configuration and mode changes don’t affect other sessions
  • Persistent Identity - Sessions can be saved, loaded, and resumed
  • MCP Connections - Each session connects to its own set of MCP servers
Think of sessions like browser tabs - each is independent but part of the same application.

Session Lifecycle

Sessions progress through several states:

Creating Sessions

New Sessions

Create a new session with session/new:
src/acp.ts
The agent returns a unique sessionId that must be included in all subsequent requests for this session.

Session ID Format

src/schema/types.gen.ts
Session IDs are opaque strings generated by the agent. Clients should treat them as opaque identifiers.

Loading Sessions

Load an existing session to restore conversation history:
src/acp.ts
Loading sessions requires the agent to advertise loadSession: true in its capabilities.

How Loading Works

  1. Client sends session/load request with existing session ID
  2. Agent restores session state from storage
  3. Agent streams conversation history via session/update notifications
  4. Client rebuilds UI state from the streamed messages
  5. Agent responds when streaming is complete
  6. Session ready for new prompts

Resuming Sessions (Unstable)

Resume a session without replaying history:
src/acp.ts
This is an unstable feature (unstable_resumeSession) and may change in future versions.

Forking Sessions (Unstable)

Create a new session based on an existing one:
src/acp.ts

Use Cases for Forking

  • Generate Summaries - Fork to create a summary without affecting main conversation
  • Try Alternatives - Fork to explore different approaches in parallel
  • Experimentation - Test agent behavior without modifying original session

Listing Sessions (Unstable)

Query available sessions:
src/acp.ts

Session State Management

Session Modes

Agents can support different operational modes that affect behavior:
src/acp.ts
Modes typically affect:
  • System prompts - Different instructions for the LLM
  • Tool availability - Which tools are accessible
  • Permission behavior - Automatic vs. manual approval
Available modes are returned in NewSessionResponse.availableModes and LoadSessionResponse.availableModes.

Session Configuration

Set configuration options for a session:
src/acp.ts

Session Model (Unstable)

Select which LLM to use for a session:
src/acp.ts

Processing Prompts

Once a session is created, send prompts to the agent:
src/acp.ts

Prompt Lifecycle

Receiving Updates

Clients receive real-time updates via notifications:

Cancelling Operations

Cancel an ongoing prompt:
src/acp.ts
The agent may send additional session/update notifications before responding with the cancelled status.

Session Persistence

Agents are responsible for persisting session state:

Best Practices

Always validate that session IDs exist and are accessible:
Every session-related operation requires the session ID:
When loading sessions, batch updates to avoid overwhelming the client:
Clean up resources when sessions end:

Session Information

Sessions include metadata for organization:

MCP Server Connections

Each session can connect to MCP servers for additional tools:
MCP servers are connected at session creation/load and provide tools and resources to the agent.

Learn More

Protocol Overview

Understanding the ACP specification

Connections

Establishing agent-client connections

Session Setup

Full specification for session operations

Prompt Turn

How prompts are processed in sessions