Skip to main content

Session Interface

Represents a series of interactions between a user and agents. Sessions store conversation state, events, and metadata that persist across multiple agent interactions.

Properties

id
string
required
The unique identifier of the session.
appName
string
required
The name of the app.
userId
string
required
The id of the user.
state
Record<string, any>
required
The state of the session. This is a key-value store that persists across events and can be updated by agents through state deltas.
Keys starting with temp_ are treated as temporary and won’t be persisted to the session state.
events
Event[]
required
The events of the session, including:
  • User input
  • Model responses
  • Function calls and responses
  • Tool executions
  • State changes
Each event represents a discrete action or message in the conversation flow.
lastUpdateTime
number
required
The last update time of the session (timestamp in milliseconds).

Usage Example

import { Session } from '@iqai/adk';

// Example session object
const session: Session = {
  id: 'session-123',
  appName: 'my-agent-app',
  userId: 'user-456',
  state: {
    userName: 'John',
    conversationCount: 5
  },
  events: [
    // Array of Event objects from the conversation
  ],
  lastUpdateTime: Date.now()
};

Build docs developers (and LLMs) love