adk-session 0.1.8

Session management and state persistence for Rust Agent Development Kit (ADK-Rust) agents
Documentation

adk-session

Session management and state persistence for Rust Agent Development Kit (ADK-Rust) agents.

Crates.io Documentation License

Overview

adk-session provides session and state management for the Rust Agent Development Kit (ADK-Rust):

  • InMemorySessionService - Simple in-memory session storage
  • State Management - Key-value state with typed prefixes
  • Event History - Conversation history tracking
  • Session Lifecycle - Create, update, and restore sessions

Installation

[dependencies]
adk-session = "0.1.8"

Or use the meta-crate:

[dependencies]
adk-rust = { version = "0.1.8", features = ["sessions"] }

Quick Start

use adk_session::InMemorySessionService;
use adk_core::Session;

// Create session service
let service = InMemorySessionService::new();

// Create a new session
let session = service.create_session("app_name", "user_123").await?;

// Access state
session.state().set("user:name", "Alice".into());
let name = session.state().get("user:name");

State Prefixes

ADK uses prefixes to organize state:

Prefix Purpose Persistence
user: User preferences Across sessions
app: Application state Application-wide
temp: Temporary data Current turn only
// User state persists
session.state().set("user:theme", "dark".into());

// Temp state cleared each turn
session.state().set("temp:current_step", "2".into());

Features

  • Thread-safe with async/await
  • Automatic event history management
  • Pluggable storage backends
  • Optional SQLite persistence (database feature)

Feature Flags

[dependencies]
adk-session = { version = "0.1.8", features = ["database"] }
  • database - Enable SQLite-backed sessions

Related Crates

License

Apache-2.0

Part of ADK-Rust

This crate is part of the ADK-Rust framework for building AI agents in Rust.