Skip to main content

Module 03: Sessions

Understanding session creation and lifecycle in ACP.

What You’ll Learn

  • Creating sessions with NewSessionRequest
  • Working directory context and context documents
  • Multiple independent sessions

How Sessions Work

Sessions are workspaces for conversations. Each session has a unique ID assigned by the agent, a working directory context, and its own conversation history. Multiple sessions on the same connection are fully independent.

The Code

After initializing (Module 01/02), the next step is creating a session. NewSessionRequest takes a working directory path and an optional list of MCP server configs. The agent returns a session ID that you use for all subsequent prompts:
You can create multiple sessions on the same connection. Each maintains its own conversation history — prompts in one session don’t affect the other:

Source Code

View on GitHub

Running the Example

Next Module

Module 04: Prompts — prompt requests and response handling in depth.