What is a session?
A session is an interaction between a user (or multiple users) and an AI agent where messages and data are exchanged, building up shared context over time. In AI Transport, sessions are designed to persist beyond the boundaries of individual connections, enabling modern AI experiences where users expect to:- Resume conversations across devices: Start a conversation on mobile and seamlessly continue on desktop with full context preserved
- Return to long-running work: Close the browser while agents continue processing in the background, delivering results when you return
- Recover from interruptions: Experience connection drops, browser refreshes, or network instability without losing conversation progress
- Collaborate in shared sessions: Multiple users can participate in the same conversation simultaneously and remain in sync
Connection-oriented vs channel-oriented sessions
In traditional connection-oriented architectures, sessions are bound to the lifecycle of a WebSocket or SSE connection:- Client opens connection to agent server to establish a session
- Agent streams response over the connection
- When the connection closes, the session ends
- Client sends a single request to agent server to establish a session
- Server responds with a unique ID for the session, which is used to identify the channel
- All further communication happens over the channel
The channel-oriented model provides key benefits for modern AI applications: sessions maintain continuity in the face of disconnections, users can refresh or navigate back to the ongoing session, multiple users or devices can participate in the same session, and agents can continue long-running or asynchronous workloads even when clients disconnect.
The following table compares how each architecture addresses the engineering challenges of delivering these capabilities:
Identity in channel-oriented sessions
In connection-oriented architectures, the agent server handles authentication directly when establishing the connection. When the connection is opened, the server verifies credentials and associates the authenticated user identity with that specific connection. In channel-oriented sessions, agents don’t manage connections or handle authentication directly. Instead, your server authenticates users and issues tokens that control their access to channels. Ably enforces these authorization rules and provides verified identity information to agents, giving you powerful capabilities for managing who can participate in sessions and what they can do:- Verified identity: Agents automatically receive the authenticated identity of message senders, with cryptographic guarantees that identities cannot be spoofed
- Fine-grained authorization: Control precisely what operations each user can perform on specific channels through fine-grained capabilities
- Rich user attributes: Pass authenticated user data to agents for personalized behavior without building custom token systems
- Role-based participation: Distinguish between different types of participants, such as users and agents, to customize behaviour based on their role
