Skip to main content

adk_session/
lib.rs

1//! # adk-session
2//!
3//! Session management and state persistence for ADK agents.
4//!
5//! ## Overview
6//!
7//! This crate provides session and state management:
8//!
9//! - [`InMemorySessionService`] - Simple in-memory session storage
10//! - `VertexAiSessionService` - Vertex AI Session API backend (`vertex-session` feature)
11//! - [`Session`] - Conversation session with state and events
12//! - [`State`] - Key-value state with typed prefixes
13//! - [`SessionService`] - Trait for custom session backends
14//!
15//! ## Quick Start
16//!
17//! ```rust,no_run
18//! use adk_session::InMemorySessionService;
19//!
20//! let service = InMemorySessionService::new();
21//!
22//! // Sessions are created and managed by the Runner
23//! // State is accessed via the session
24//! ```
25//!
26//! ## State Prefixes
27//!
28//! ADK uses prefixes to organize state:
29//!
30//! | Prefix | Constant | Purpose |
31//! |--------|----------|---------|
32//! | `user:` | [`KEY_PREFIX_USER`] | User preferences |
33//! | `app:` | [`KEY_PREFIX_APP`] | Application state |
34//! | `temp:` | [`KEY_PREFIX_TEMP`] | Temporary data |
35
36pub mod event;
37pub mod inmemory;
38pub mod service;
39pub mod session;
40pub mod state;
41
42#[cfg(feature = "database")]
43pub mod database;
44#[cfg(feature = "vertex-session")]
45pub mod vertex;
46
47pub use event::{Event, EventActions, Events};
48pub use inmemory::InMemorySessionService;
49pub use service::{CreateRequest, DeleteRequest, GetRequest, ListRequest, SessionService};
50pub use session::{KEY_PREFIX_APP, KEY_PREFIX_TEMP, KEY_PREFIX_USER, Session};
51pub use state::{ReadonlyState, State};
52
53#[cfg(feature = "database")]
54pub use database::DatabaseSessionService;
55#[cfg(feature = "vertex-session")]
56pub use vertex::{VertexAiSessionConfig, VertexAiSessionService};