Skip to main content

Module 09: Session Resume

Load and resume existing sessions.

What You’ll Learn

  • Using client.loadSession() to resume a session by ID
  • LoadSessionRequest and LoadSessionResponse structure
  • Session state persistence across load operations

How It Works

loadSession() tells the agent to resume a previously created session. The agent looks up its stored state for that session ID and restores the conversation context. Whether state actually persists depends on the agent implementation — the demo includes a StatefulAgent that stores session history in a ConcurrentHashMap.

The Code

This example creates a session, sends messages to build history, then loads the same session by ID. After loading, the agent has access to the previous conversation context:

Source Code

View on GitHub

Running the Example

Next Module

Module 10: Cancellation — cancel an in-progress prompt.