#agent-state #adk #api-bindings #ai-agent

adk-session

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

16 unstable releases (3 breaking)

Uses new Rust 2024

new 0.4.0 Mar 16, 2026
0.3.2 Feb 21, 2026
0.2.1 Jan 22, 2026
0.1.9 Jan 3, 2026
0.1.1 Nov 30, 2025

#1648 in Asynchronous

Download history 1/week @ 2025-11-30 32/week @ 2025-12-07 4/week @ 2025-12-14 3/week @ 2025-12-28 1/week @ 2026-01-04 1/week @ 2026-01-11 34/week @ 2026-01-18 54/week @ 2026-01-25 43/week @ 2026-02-01 38/week @ 2026-02-08 57/week @ 2026-02-15 60/week @ 2026-02-22 112/week @ 2026-03-01 280/week @ 2026-03-08

523 downloads per month
Used in 8 crates (7 directly)

Apache-2.0

410KB
8K SLoC

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
  • SqliteSessionService - SQLite-backed persistence (sqlite feature)
  • PostgresSessionService - PostgreSQL-backed persistence (postgres feature)
  • RedisSessionService - Redis-backed persistence (redis feature)
  • MongoSessionService - MongoDB-backed persistence (mongodb feature)
  • Neo4jSessionService - Neo4j-backed persistence (neo4j feature)
  • FirestoreSessionService - Firestore-backed persistence (firestore feature)
  • VertexAiSessionService - Vertex AI Session API backend (vertex-session feature)
  • Schema Migrations - Versioned, forward-only migrations for all database backends

Installation

[dependencies]
adk-session = "0.4"

Or use the meta-crate:

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

Quick Start

use adk_session::{InMemorySessionService, SessionService, CreateRequest, KEY_PREFIX_USER};
use serde_json::json;
use std::collections::HashMap;

let service = InMemorySessionService::new();

let mut initial_state = HashMap::new();
initial_state.insert(format!("{}name", KEY_PREFIX_USER), json!("Alice"));

let session = service.create(CreateRequest {
    app_name: "my_app".to_string(),
    user_id: "user_123".to_string(),
    session_id: None,
    state: initial_state,
}).await?;

let name = session.state().get("user:name");

State Prefixes

Prefix Purpose Persistence
user: User preferences Across sessions
app: Application state Application-wide
temp: Temporary data Current turn only

Feature Flags

Feature Backend Description
sqlite SQLite Single-node persistence via sqlx
database SQLite Alias for sqlite (backward compat)
postgres PostgreSQL Production-grade relational persistence
redis Redis Low-latency in-memory persistence via fred
mongodb MongoDB Document-oriented persistence
neo4j Neo4j Graph database persistence
firestore Firestore Google Cloud Firestore persistence
vertex-session Vertex AI Vertex AI Session API backend
# SQLite
adk-session = { version = "0.4", features = ["sqlite"] }

# PostgreSQL
adk-session = { version = "0.4", features = ["postgres"] }

# Redis
adk-session = { version = "0.4", features = ["redis"] }

Schema Migrations

All database backends (SQLite, PostgreSQL, MongoDB, Neo4j) include a versioned migration system. Migrations are forward-only, idempotent, and tracked in a _schema_migrations registry table.

use adk_session::SqliteSessionService;

let service = SqliteSessionService::new("sqlite:sessions.db").await?;

// Run all pending migrations
service.migrate().await?;

// Check current schema version
let version = service.schema_version().await?;
println!("Schema version: {version}");

Each backend detects pre-existing tables (baseline detection) and registers them as already applied, so migrate() is safe to call on both fresh and existing databases.

Rename: DatabaseSessionService → SqliteSessionService

As of v0.4.0, DatabaseSessionService has been renamed to SqliteSessionService to accurately reflect that it is a SQLite-only backend. A deprecated type alias is provided for backward compatibility:

// Old (still compiles with a deprecation warning)
use adk_session::DatabaseSessionService;

// New
use adk_session::SqliteSessionService;

License

Apache-2.0

Part of ADK-Rust

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

Dependencies

~7–54MB
~826K SLoC