adk-session
Session management and state persistence for Rust Agent Development Kit (ADK-Rust) agents.
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
[]
= "0.1.8"
Or use the meta-crate:
[]
= { = "0.1.8", = ["sessions"] }
Quick Start
use InMemorySessionService;
use Session;
// Create session service
let service = new;
// Create a new session
let session = service.create_session.await?;
// Access state
session.state.set;
let name = session.state.get;
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;
// Temp state cleared each turn
session.state.set;
Features
- Thread-safe with async/await
- Automatic event history management
- Pluggable storage backends
- Optional SQLite persistence (
databasefeature)
Feature Flags
[]
= { = "0.1.8", = ["database"] }
database- Enable SQLite-backed sessions
Related Crates
- adk-rust - Meta-crate with all components
- adk-core - Core
Sessiontrait - adk-runner - Uses sessions for execution
License
Apache-2.0
Part of ADK-Rust
This crate is part of the ADK-Rust framework for building AI agents in Rust.