Google ADK¶
Session, event, memory, and artifact storage backends for Google Agent Development Kit.
Session Service¶
- class sqlspec.extensions.adk.SQLSpecSessionService[source]¶
Bases:
BaseSessionServiceSQLSpec-backed implementation of BaseSessionService.
Provides session and event storage using SQLSpec database adapters. Delegates all database operations to a store implementation.
- Parameters:
store¶ (
BaseAsyncADKStore) -- Database store implementation (e.g., AsyncpgADKStore).
Example
from sqlspec.adapters.asyncpg import AsyncpgConfig from sqlspec.adapters.asyncpg.adk.store import AsyncpgADKStore from sqlspec.extensions.adk.service import SQLSpecSessionService
config = AsyncpgConfig(connection_config={"dsn": "postgresql://..."}) store = AsyncpgADKStore(config) await store.ensure_tables()
service = SQLSpecSessionService(store) session = await service.create_session(
app_name="my_app", user_id="user123", state={"key": "value"}
)
- __init__(store)[source]¶
Initialize the session service.
- Parameters:
store¶ (
BaseAsyncADKStore) -- Database store implementation.
- property store: BaseAsyncADKStore¶
Return the database store.
- async create_session(*, app_name, user_id, state=None, session_id=None)[source]¶
Create a new session.
- Parameters:
- Return type:
Session- Returns:
The newly created session.
- async list_sessions(*, app_name, user_id=None)[source]¶
List all sessions for an app, optionally filtered by user.
- async delete_session(*, app_name, user_id, session_id)[source]¶
Delete a session and all its events.
- async append_event(session, event)[source]¶
Append an event to a session.
Persists the event record and the post-append durable state atomically via
store.append_event_and_update_state(), then updates the in-memory session only after persistence succeeds.Implements stale-session detection: if the session has been modified in storage since it was last loaded, a
ValueErroris raised instead of silently overwriting.temp:keys are stripped from the persisted state snapshot so they never survive a reload.- Parameters:
- Return type:
Event- Returns:
The appended event.
- Raises:
ValueError -- If the session has been modified in storage since it was loaded (stale session).
Memory Services¶
- class sqlspec.extensions.adk.SQLSpecMemoryService[source]¶
Bases:
BaseMemoryServiceSQLSpec-backed implementation of BaseMemoryService.
Provides memory entry storage using SQLSpec database adapters. Delegates all database operations to a store implementation.
ADK BaseMemoryService defines two core methods: - add_session_to_memory(session) - Ingests session into memory (returns void) - search_memory(app_name, user_id, query) - Searches stored memories
- Parameters:
store¶ (
BaseAsyncADKMemoryStore) -- Database store implementation (e.g., AsyncpgADKMemoryStore).
Example
from sqlspec.adapters.asyncpg import AsyncpgConfig from sqlspec.adapters.asyncpg.adk.store import AsyncpgADKMemoryStore from sqlspec.extensions.adk.memory.service import SQLSpecMemoryService
- config = AsyncpgConfig(
connection_config={"dsn": "postgresql://..."}, extension_config={
- "adk": {
"memory_table": "adk_memory_entries", "memory_use_fts": True,
}
}
) store = AsyncpgADKMemoryStore(config) await store.ensure_tables()
service = SQLSpecMemoryService(store) await service.add_session_to_memory(completed_session)
- response = await service.search_memory(
app_name="my_app", user_id="user123", query="previous conversation about Python"
)
- __init__(store)[source]¶
Initialize the memory service.
- Parameters:
store¶ (
BaseAsyncADKMemoryStore) -- Database store implementation.
- property store: BaseAsyncADKMemoryStore¶
Return the database store.
- async add_session_to_memory(session)[source]¶
Add a completed session to the memory store.
Extracts all events with content from the session and stores them as searchable memory entries. Uses UPSERT to skip duplicates.
The Session object contains app_name and user_id properties. Events are converted to memory records and bulk inserted via store. Returns void per ADK BaseMemoryService contract.
Notes
Events without content are skipped
Duplicate event_ids are silently ignored (idempotent)
Uses bulk insert for efficiency
- async add_events_to_memory(*, app_name, user_id, events, session_id=None, custom_metadata=None)[source]¶
Add an explicit list of events to the memory service.
Same Event-to-MemoryRecord extraction logic as
add_session_to_memory, but operates on a sequence of Events directly (no Session wrapper needed).
- async add_memory(*, app_name, user_id, memories, custom_metadata=None)[source]¶
Add explicit memory items directly to the memory service.
Each entry's
contentis serialized tocontent_json, text is extracted fromcontent.partsforcontent_text, andcustom_metadatamerges the entry-levelentry.custom_metadatawith the call-levelcustom_metadataparameter.
- class sqlspec.extensions.adk.SQLSpecSyncMemoryService[source]¶
Bases:
objectSynchronous SQLSpec-backed memory service.
Provides memory entry storage using SQLSpec sync database adapters. This is a sync-compatible version for use with sync drivers like SQLite.
Note: This does NOT inherit from BaseMemoryService since ADK's base class requires async methods. Use this for sync-only deployments.
- Parameters:
store¶ (
BaseSyncADKMemoryStore) -- Sync database store implementation.
Example
from sqlspec.adapters.sqlite import SqliteConfig from sqlspec.adapters.sqlite.adk.store import SqliteADKMemoryStore from sqlspec.extensions.adk.memory.service import SQLSpecSyncMemoryService
- config = SqliteConfig(
connection_config={"database": "app.db"}, extension_config={
- "adk": {
"memory_table": "adk_memory_entries",
}
}
) store = SqliteADKMemoryStore(config) store.ensure_tables()
service = SQLSpecSyncMemoryService(store) service.add_session_to_memory(completed_session)
- memories = service.search_memory(
app_name="my_app", user_id="user123", query="Python discussion"
)
- __init__(store)[source]¶
Initialize the sync memory service.
- Parameters:
store¶ (
BaseSyncADKMemoryStore) -- Sync database store implementation.
- property store: BaseSyncADKMemoryStore¶
Return the database store.
Artifact Service¶
- class sqlspec.extensions.adk.SQLSpecArtifactService[source]¶
Bases:
BaseArtifactServiceSQLSpec-backed implementation of BaseArtifactService.
Composes SQL metadata storage with
sqlspec/storage/content backends to provide versioned artifact management for Google ADK.Metadata (version number, filename, MIME type, custom metadata, canonical URI) is stored in a SQL table managed by the artifact store. Content bytes are stored in object storage (S3, GCS, Azure, local filesystem) via the storage registry.
- Parameters:
store¶ (
BaseAsyncADKArtifactStore) -- Artifact metadata store implementation.artifact_storage_uri¶ (
str) -- Base URI for content storage (e.g.,"s3://my-bucket/adk-artifacts/","file:///var/data/artifacts/"). Can also be a registered alias in the storage registry.registry¶ (
StorageRegistry|None) -- Storage registry to use. Defaults to the global singleton.
Example
from sqlspec.adapters.asyncpg.adk.artifact_store import AsyncpgADKArtifactStore from sqlspec.extensions.adk.artifact import SQLSpecArtifactService
artifact_store = AsyncpgADKArtifactStore(config) await artifact_store.ensure_table()
- service = SQLSpecArtifactService(
store=artifact_store, artifact_storage_uri="s3://my-bucket/adk-artifacts/",
)
- version = await service.save_artifact(
app_name="my_app", user_id="user123", filename="output.png", artifact=part,
)
- property store: BaseAsyncADKArtifactStore¶
Return the artifact metadata store.
- async save_artifact(*, app_name, user_id, filename, artifact, session_id=None, custom_metadata=None)[source]¶
Save an artifact, returning the new version number.
Writes content to object storage first, then inserts the metadata row. If content write succeeds but metadata insert fails, the orphaned content blob is logged but not automatically cleaned up (eventual consistency is acceptable; orphan sweep can be added later).
- Parameters:
- Return type:
- Returns:
The version number (0-based, incrementing).
- async load_artifact(*, app_name, user_id, filename, session_id=None, version=None)[source]¶
Load an artifact by reading metadata then fetching content.
- Parameters:
- Return type:
Part|None- Returns:
Deserialized Part, or None if not found.
- async list_artifact_keys(*, app_name, user_id, session_id=None)[source]¶
List distinct artifact filenames.
When
session_idis provided, returns both session-scoped and user-scoped filenames. When None, returns only user-scoped filenames.
- async delete_artifact(*, app_name, user_id, filename, session_id=None)[source]¶
Delete an artifact and all its versions.
Deletes metadata rows first (fail-fast), then removes content objects from storage (best-effort).
- async list_versions(*, app_name, user_id, filename, session_id=None)[source]¶
List all version numbers for an artifact.
- async list_artifact_versions(*, app_name, user_id, filename, session_id=None)[source]¶
List all versions with full metadata for an artifact.
Store Base Classes¶
- class sqlspec.extensions.adk.BaseAsyncADKStore[source]¶
-
Base class for async SQLSpec-backed ADK session stores.
Implements storage operations for Google ADK sessions and events using SQLSpec database adapters with async/await.
This abstract base class provides common functionality for all database-specific store implementations including: - Connection management via SQLSpec configs - Table name validation - Session and event CRUD operations
Subclasses must implement dialect-specific SQL queries and will be created in each adapter directory (e.g., sqlspec/adapters/asyncpg/adk/store.py).
- Parameters:
config¶ (
TypeVar(ConfigT, bound= DatabaseConfigProtocol[Any, Any, Any])) -- SQLSpec database configuration with extension_config["adk"] settings.
Notes
Configuration is read from config.extension_config["adk"]: - session_table: Sessions table name (default: "adk_sessions") - events_table: Events table name (default: "adk_events") - owner_id_column: Optional owner FK column DDL (default: None)
- __init__(config)[source]¶
Initialize the ADK store.
- Parameters:
config¶ (
TypeVar(ConfigT, bound= DatabaseConfigProtocol[Any, Any, Any])) -- SQLSpec database configuration.
Notes
Reads configuration from config.extension_config["adk"]: - session_table: Sessions table name (default: "adk_sessions") - events_table: Events table name (default: "adk_events") - owner_id_column: Optional owner FK column DDL (default: None)
- property config: ConfigT¶
Return the database configuration.
- property owner_id_column_ddl: str | None¶
Return the full owner ID column DDL (or None if not configured).
- property owner_id_column_name: str | None¶
Return the owner ID column name only (or None if not configured).
- abstractmethod async create_session(session_id, app_name, user_id, state, owner_id=None)[source]¶
Create a new session.
- Parameters:
- Return type:
- Returns:
The created session record.
- abstractmethod async get_session(session_id)[source]¶
Get a session by ID.
- Parameters:
- Return type:
- Returns:
Session record if found, None otherwise.
- abstractmethod async list_sessions(app_name, user_id=None)[source]¶
List all sessions for an app, optionally filtered by user.
- abstractmethod async append_event(event_record)[source]¶
Append an event to a session.
- Parameters:
event_record¶ (
EventRecord) -- Event record to store.- Return type:
- abstractmethod async append_event_and_update_state(event_record, session_id, state)[source]¶
Atomically append an event and update the session's durable state.
This is the authoritative durable write boundary for post-creation session mutations. The event insert and state update must succeed together or fail together.
- abstractmethod async get_events(session_id, after_timestamp=None, limit=None)[source]¶
Get events for a session.
- class sqlspec.extensions.adk.BaseSyncADKStore[source]¶
-
Base class for sync SQLSpec-backed ADK session stores.
Implements storage operations for Google ADK sessions and events using SQLSpec database adapters with synchronous execution.
This abstract base class provides common functionality for sync database-specific store implementations including: - Connection management via SQLSpec configs - Table name validation - Session and event CRUD operations
Subclasses must implement dialect-specific SQL queries and will be created in each adapter directory (e.g., sqlspec/adapters/sqlite/adk/store.py).
- Parameters:
config¶ (
TypeVar(ConfigT, bound= DatabaseConfigProtocol[Any, Any, Any])) -- SQLSpec database configuration with extension_config["adk"] settings.
Notes
Configuration is read from config.extension_config["adk"]: - session_table: Sessions table name (default: "adk_sessions") - events_table: Events table name (default: "adk_events") - owner_id_column: Optional owner FK column DDL (default: None)
- __init__(config)[source]¶
Initialize the sync ADK store.
- Parameters:
config¶ (
TypeVar(ConfigT, bound= DatabaseConfigProtocol[Any, Any, Any])) -- SQLSpec database configuration.
Notes
Reads configuration from config.extension_config["adk"]: - session_table: Sessions table name (default: "adk_sessions") - events_table: Events table name (default: "adk_events") - owner_id_column: Optional owner FK column DDL (default: None)
- property config: ConfigT¶
Return the database configuration.
- property owner_id_column_ddl: str | None¶
Return the full owner ID column DDL (or None if not configured).
- property owner_id_column_name: str | None¶
Return the owner ID column name only (or None if not configured).
- abstractmethod create_session(session_id, app_name, user_id, state, owner_id=None)[source]¶
Create a new session.
- Parameters:
- Return type:
- Returns:
The created session record.
- abstractmethod get_session(session_id)[source]¶
Get a session by ID.
- Parameters:
- Return type:
- Returns:
Session record if found, None otherwise.
- abstractmethod list_sessions(app_name, user_id=None)[source]¶
List all sessions for an app, optionally filtered by user.
- abstractmethod create_event(event_id, session_id, app_name, user_id, author=None, actions=None, content=None, **kwargs)[source]¶
Create a new event.
- abstractmethod create_event_and_update_state(event_record, session_id, state)[source]¶
Atomically create an event and update the session's durable state.
This is the authoritative durable write boundary for post-creation session mutations. The event insert and state update must succeed together or fail together.
- abstractmethod list_events(session_id)[source]¶
List events for a session ordered by timestamp.
- Parameters:
- Return type:
- Returns:
List of event records ordered by timestamp ASC.
Memory Store Base Classes¶
- class sqlspec.extensions.adk.BaseAsyncADKMemoryStore[source]¶
-
Base class for async SQLSpec-backed ADK memory stores.
Implements storage operations for Google ADK memory entries using SQLSpec database adapters with async/await.
This abstract base class provides common functionality for all database-specific memory store implementations including: - Connection management via SQLSpec configs - Table name validation - Memory entry CRUD operations - Text search with optional full-text search support
Subclasses must implement dialect-specific SQL queries and will be created in each adapter directory (e.g., sqlspec/adapters/asyncpg/adk/store.py).
- Parameters:
config¶ (
TypeVar(ConfigT, bound= DatabaseConfigProtocol[Any, Any, Any])) -- SQLSpec database configuration with extension_config["adk"] settings.
Notes
Configuration is read from config.extension_config["adk"]: - memory_table: Memory table name (default: "adk_memory_entries") - memory_use_fts: Enable full-text search when supported (default: False) - memory_max_results: Max search results (default: 20) - owner_id_column: Optional owner FK column DDL (default: None) - enable_memory: Whether memory is enabled (default: True)
- __init__(config)[source]¶
Initialize the ADK memory store.
- Parameters:
config¶ (
TypeVar(ConfigT, bound= DatabaseConfigProtocol[Any, Any, Any])) -- SQLSpec database configuration.
Notes
Reads configuration from config.extension_config["adk"]: - memory_table: Memory table name (default: "adk_memory_entries") - memory_use_fts: Enable full-text search when supported (default: False) - memory_max_results: Max search results (default: 20) - owner_id_column: Optional owner FK column DDL (default: None) - enable_memory: Whether memory is enabled (default: True)
- property config: ConfigT¶
Return the database configuration.
- property owner_id_column_ddl: str | None¶
Return the full owner ID column DDL (or None if not configured).
- property owner_id_column_name: str | None¶
Return the owner ID column name only (or None if not configured).
- abstractmethod async create_tables()[source]¶
Create the memory table and indexes if they don't exist.
Should check self._enabled and skip table creation if False.
- Return type:
- async ensure_tables()[source]¶
Create tables when enabled and emit a standardized log entry.
- Return type:
- abstractmethod async insert_memory_entries(entries, owner_id=None)[source]¶
Bulk insert memory entries with deduplication.
Uses UPSERT pattern to skip duplicates based on event_id.
- Parameters:
- Return type:
- Returns:
Number of entries actually inserted (excludes duplicates).
- Raises:
RuntimeError -- If memory store is disabled.
- abstractmethod async search_entries(query, app_name, user_id, limit=None)[source]¶
Search memory entries by text query.
Uses the configured search strategy (simple ILIKE or FTS).
- Parameters:
- Return type:
- Returns:
List of matching memory records ordered by relevance/timestamp.
- Raises:
RuntimeError -- If memory store is disabled.
- class sqlspec.extensions.adk.BaseSyncADKMemoryStore[source]¶
-
Base class for sync SQLSpec-backed ADK memory stores.
Implements storage operations for Google ADK memory entries using SQLSpec database adapters with synchronous execution.
This abstract base class provides common functionality for sync database-specific memory store implementations including: - Connection management via SQLSpec configs - Table name validation - Memory entry CRUD operations - Text search with optional full-text search support
Subclasses must implement dialect-specific SQL queries and will be created in each adapter directory (e.g., sqlspec/adapters/sqlite/adk/store.py).
- Parameters:
config¶ (
TypeVar(ConfigT, bound= DatabaseConfigProtocol[Any, Any, Any])) -- SQLSpec database configuration with extension_config["adk"] settings.
Notes
Configuration is read from config.extension_config["adk"]: - memory_table: Memory table name (default: "adk_memory_entries") - memory_use_fts: Enable full-text search when supported (default: False) - memory_max_results: Max search results (default: 20) - owner_id_column: Optional owner FK column DDL (default: None) - enable_memory: Whether memory is enabled (default: True)
- __init__(config)[source]¶
Initialize the sync ADK memory store.
- Parameters:
config¶ (
TypeVar(ConfigT, bound= DatabaseConfigProtocol[Any, Any, Any])) -- SQLSpec database configuration.
Notes
Reads configuration from config.extension_config["adk"]: - memory_table: Memory table name (default: "adk_memory_entries") - memory_use_fts: Enable full-text search when supported (default: False) - memory_max_results: Max search results (default: 20) - owner_id_column: Optional owner FK column DDL (default: None) - enable_memory: Whether memory is enabled (default: True)
- property config: ConfigT¶
Return the database configuration.
- property owner_id_column_ddl: str | None¶
Return the full owner ID column DDL (or None if not configured).
- property owner_id_column_name: str | None¶
Return the owner ID column name only (or None if not configured).
- abstractmethod create_tables()[source]¶
Create the memory table and indexes if they don't exist.
Should check self._enabled and skip table creation if False.
- Return type:
- abstractmethod insert_memory_entries(entries, owner_id=None)[source]¶
Bulk insert memory entries with deduplication.
Uses UPSERT pattern to skip duplicates based on event_id.
- Parameters:
- Return type:
- Returns:
Number of entries actually inserted (excludes duplicates).
- Raises:
RuntimeError -- If memory store is disabled.
- abstractmethod search_entries(query, app_name, user_id, limit=None)[source]¶
Search memory entries by text query.
Uses the configured search strategy (simple ILIKE or FTS).
- Parameters:
- Return type:
- Returns:
List of matching memory records ordered by relevance/timestamp.
- Raises:
RuntimeError -- If memory store is disabled.
Artifact Store Base Classes¶
- class sqlspec.extensions.adk.BaseAsyncADKArtifactStore[source]¶
-
Base class for async SQLSpec-backed ADK artifact metadata stores.
Manages artifact version metadata in a SQL table. Content bytes are stored externally via
sqlspec/storage/backends and referenced by canonical URI in each metadata row.Subclasses must implement dialect-specific SQL queries.
- Parameters:
config¶ (
TypeVar(ConfigT, bound= DatabaseConfigProtocol[Any, Any, Any])) -- SQLSpec database configuration with extension_config["adk"] settings.
Notes
Configuration is read from config.extension_config["adk"]: - artifact_table: Artifact versions table name (default: "adk_artifact_versions")
- property config: ConfigT¶
Return the database configuration.
- abstractmethod async insert_artifact(record)[source]¶
Insert an artifact version metadata row.
- Parameters:
record¶ (
ArtifactRecord) -- Artifact metadata record to insert.- Return type:
- abstractmethod async get_artifact(app_name, user_id, filename, session_id=None, version=None)[source]¶
Get a specific artifact version's metadata.
When
versionis None, returns the latest version.- Parameters:
- Return type:
- Returns:
Artifact record if found, None otherwise.
- abstractmethod async list_artifact_keys(app_name, user_id, session_id=None)[source]¶
List distinct artifact filenames.
When
session_idis provided, returns filenames from both session-scoped and user-scoped artifacts. When None, returns only user-scoped artifact filenames.
- abstractmethod async list_artifact_versions(app_name, user_id, filename, session_id=None)[source]¶
List all version records for an artifact, ordered by version ascending.
- abstractmethod async delete_artifact(app_name, user_id, filename, session_id=None)[source]¶
Delete all version records for an artifact and return them.
The caller uses the returned records to clean up content from object storage. Metadata is deleted first (fail-fast); content cleanup is best-effort.
- abstractmethod async get_next_version(app_name, user_id, filename, session_id=None)[source]¶
Get the next version number for an artifact.
Returns 0 if no versions exist (first version), otherwise
max(version) + 1.
- class sqlspec.extensions.adk.BaseSyncADKArtifactStore[source]¶
-
Base class for sync SQLSpec-backed ADK artifact metadata stores.
Synchronous counterpart of
BaseAsyncADKArtifactStore.- Parameters:
config¶ (
TypeVar(ConfigT, bound= DatabaseConfigProtocol[Any, Any, Any])) -- SQLSpec database configuration with extension_config["adk"] settings.
- property config: ConfigT¶
Return the database configuration.
- abstractmethod insert_artifact(record)[source]¶
Insert an artifact version metadata row.
- Parameters:
record¶ (
ArtifactRecord) -- Artifact metadata record to insert.- Return type:
- abstractmethod get_artifact(app_name, user_id, filename, session_id=None, version=None)[source]¶
Get a specific artifact version's metadata.
When
versionis None, returns the latest version.- Parameters:
- Return type:
- Returns:
Artifact record if found, None otherwise.
- abstractmethod list_artifact_keys(app_name, user_id, session_id=None)[source]¶
List distinct artifact filenames.
- abstractmethod list_artifact_versions(app_name, user_id, filename, session_id=None)[source]¶
List all version records for an artifact, ordered by version ascending.
- abstractmethod delete_artifact(app_name, user_id, filename, session_id=None)[source]¶
Delete all version records for an artifact and return them.
- abstractmethod get_next_version(app_name, user_id, filename, session_id=None)[source]¶
Get the next version number for an artifact.
Record Types¶
- class sqlspec.extensions.adk.SessionRecord[source]¶
Bases:
TypedDictDatabase record for a session.
Represents the schema for sessions stored in the database.
- class sqlspec.extensions.adk.EventRecord[source]¶
Bases:
TypedDictDatabase record for an event.
Stores the full ADK Event as a single JSON blob (
event_json) alongside a small number of indexed scalar columns used for query filtering.This design eliminates column drift with upstream ADK: new Event fields are automatically captured in
event_jsonwithout schema changes.
- class sqlspec.extensions.adk.MemoryRecord[source]¶
Bases:
TypedDictDatabase record for a memory entry.
Represents the schema for memory entries stored in the database. Contains extracted content from ADK events for searchable long-term memory.
- class sqlspec.extensions.adk.ArtifactRecord[source]¶
Bases:
TypedDictDatabase record for an artifact version.
Represents the schema for artifact metadata stored in the database. Content is stored separately in object storage; this record tracks versioning, ownership, and the canonical URI pointing to the content.
The composite key is (app_name, user_id, session_id, filename, version), where session_id may be NULL for user-scoped artifacts.
Configuration¶
- class sqlspec.extensions.adk.ADKConfig[source]¶
Bases:
TypedDictConfiguration options for ADK session and memory store extension.
All fields are optional with sensible defaults. Use in extension_config["adk"]:
Configuration supports three deployment scenarios: 1. SQLSpec manages everything (runtime + migrations) 2. SQLSpec runtime only (external migration tools like Alembic/Flyway) 3. Selective features (sessions OR memory, not both)
Example
from sqlspec.adapters.asyncpg import AsyncpgConfig
- config = AsyncpgConfig(
connection_config={"dsn": "postgresql://localhost/mydb"}, extension_config={
- "adk": {
"session_table": "my_sessions", "events_table": "my_events", "memory_table": "my_memories", "memory_use_fts": True, "owner_id_column": "tenant_id INTEGER REFERENCES tenants(id)"
}
}
)
Notes
This TypedDict provides type safety for extension config but is not required. You can use plain dicts as well.
- enable_sessions: NotRequired[bool]¶
True.
When False: session service unavailable, session store operations disabled. Independent of migration control - can use externally-managed tables.
- Type:
Enable session store at runtime. Default
- enable_memory: NotRequired[bool]¶
True.
When False: memory service unavailable, memory store operations disabled. Independent of migration control - can use externally-managed tables.
- Type:
Enable memory store at runtime. Default
- include_sessions_migration: NotRequired[bool]¶
True.
When False: session migration DDL skipped (use external migration tools). Decoupled from enable_sessions - allows external table management with SQLSpec runtime.
- Type:
Include session tables in SQLSpec migrations. Default
- include_memory_migration: NotRequired[bool]¶
True.
When False: memory migration DDL skipped (use external migration tools). Decoupled from enable_memory - allows external table management with SQLSpec runtime.
- Type:
Include memory tables in SQLSpec migrations. Default
- session_table: NotRequired[str]¶
'adk_sessions'
Examples
"agent_sessions" "my_app_sessions" "tenant_acme_sessions"
- Type:
Name of the sessions table. Default
- events_table: NotRequired[str]¶
'adk_events'
Examples
"agent_events" "my_app_events" "tenant_acme_events"
- Type:
Name of the events table. Default
- memory_table: NotRequired[str]¶
'adk_memory_entries'
Examples
"agent_memories" "my_app_memories" "tenant_acme_memories"
- Type:
Name of the memory entries table. Default
- artifact_table: NotRequired[str]¶
'adk_artifact_versions'
Examples
"agent_artifacts" "my_app_artifact_versions"
- Type:
Name of the artifact versions table. Default
- artifact_storage_uri: NotRequired[str]¶
Base URI for artifact content storage.
Points to a
sqlspec/storage/backend where artifact binary content is stored. Can be a direct URI (s3://bucket/path,file:///path) or a registered alias in the storage registry.Examples
"s3://my-bucket/adk-artifacts/" "file:///var/data/artifacts/" "gcs://my-gcs-bucket/artifacts/"
- memory_use_fts: NotRequired[bool]¶
False.
When True, adapters will use their native FTS capabilities where available: - PostgreSQL: to_tsvector/to_tsquery with GIN index - SQLite: FTS5 virtual table - DuckDB: FTS extension with match_bm25 - Oracle: CONTAINS() with CTXSYS.CONTEXT index - BigQuery: SEARCH() function (requires search index) - Spanner: TOKENIZE_FULLTEXT with search index - MySQL: MATCH...AGAINST with FULLTEXT index
When False, adapters use simple LIKE/ILIKE queries (works without indexes).
- Type:
Enable full-text search when supported. Default
- memory_max_results: NotRequired[int]¶
Limits the number of memory entries returned by search_memory(). Can be overridden per-query via the limit parameter.
- Type:
Maximum number of results for memory search queries. Default
- owner_id_column: NotRequired[str]¶
Optional owner ID column definition to link sessions/memories to a user, tenant, team, or other entity.
Format: "column_name TYPE [NOT NULL] REFERENCES table(column) [options...]"
The entire definition is passed through to DDL verbatim. We only parse the column name (first word) for use in INSERT/SELECT statements.
This column is added to both session and memory tables for consistent multi-tenant isolation.
- Supports:
Foreign key constraints: REFERENCES table(column)
Nullable or NOT NULL
CASCADE options: ON DELETE CASCADE, ON UPDATE CASCADE
Dialect-specific options (DEFERRABLE, ENABLE VALIDATE, etc.)
Plain columns without FK (just extra column storage)
Examples
- PostgreSQL with UUID FK:
"account_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE"
- MySQL with BIGINT FK:
"user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE RESTRICT"
- Oracle with NUMBER FK:
"user_id NUMBER(10) REFERENCES users(id) ENABLE VALIDATE"
- SQLite with INTEGER FK:
"tenant_id INTEGER NOT NULL REFERENCES tenants(id)"
- Nullable FK (optional relationship):
"workspace_id UUID REFERENCES workspaces(id) ON DELETE SET NULL"
- No FK (just extra column):
"organization_name VARCHAR(128) NOT NULL"
- Deferred constraint (PostgreSQL):
"user_id UUID REFERENCES users(id) DEFERRABLE INITIALLY DEFERRED"
Notes
Column name (first word) is extracted for INSERT/SELECT queries
Rest of definition is passed through to CREATE TABLE DDL
Database validates the DDL syntax (fail-fast on errors)
Works with all database dialects (PostgreSQL, MySQL, SQLite, Oracle, etc.)
- in_memory: NotRequired[bool]¶
False.
When enabled, tables are created with the INMEMORY clause for Oracle Database, which stores table data in columnar format in memory for faster query performance.
- This is an Oracle-specific feature that requires:
Oracle Database 12.1.0.2 or higher
Database In-Memory option license (Enterprise Edition)
Sufficient INMEMORY_SIZE configured in the database instance
Other database adapters ignore this setting.
Examples
- Oracle with in-memory enabled:
- config = OracleAsyncConfig(
connection_config={"dsn": "oracle://..."}, extension_config={
- "adk": {
"in_memory": True
}
}
)
Notes
Improves query performance for analytics (10-100x faster)
Tables created with INMEMORY clause
Requires Oracle Database In-Memory option license
Ignored by non-Oracle adapters
- Type:
Enable in-memory table storage (Oracle-specific). Default
- shard_count: NotRequired[int]¶
Optional hash shard count for session/event tables to reduce hotspotting.
When set (>1), adapters that support computed shard columns will create a generated shard_id using MOD(FARM_FINGERPRINT(primary_key), shard_count) and include it in the primary key and filters. Ignored by adapters that do not support computed shards.
- session_table_options: NotRequired[str]¶
Adapter-specific table OPTIONS/clauses for the sessions table.
Passed verbatim when supported (e.g., Spanner columnar/tiered storage). Ignored by adapters without table OPTIONS support.
- events_table_options: NotRequired[str]¶
Adapter-specific table OPTIONS/clauses for the events table.
- memory_table_options: NotRequired[str]¶
Adapter-specific table OPTIONS/clauses for the memory table.
- expires_index_options: NotRequired[str]¶
Adapter-specific options for the expires/index used in ADK stores.
- fts_language: NotRequired[str]¶
'english'.
Controls the language dictionary/stemmer used by FTS implementations: - PostgreSQL: to_tsvector/to_tsquery language parameter - SQLite FTS5: tokenizer language for unicode61/porter - MySQL: FULLTEXT parser language (with ngram for CJK on 5.7.6+) - Oracle: CTXSYS.CONTEXT lexer language - Spanner: TOKENIZE_FULLTEXT language parameter - DuckDB: FTS stemmer language
Only takes effect when
memory_use_ftsis True.Common values: 'english', 'simple', 'german', 'french', 'spanish', 'portuguese', 'italian', 'dutch', 'russian', 'chinese', 'japanese', 'korean'.
Notes
Available languages vary by backend. Backends that do not support the specified language will fall back to 'simple' or 'english'.
- Type:
Language configuration for full-text search indexing. Default
- schema_version: NotRequired[int]¶
None (auto-detect).
When set, locks the ADK schema to a specific version. This is useful for: - Preventing automatic schema upgrades in production - Pinning to a known-good schema during testing - Coordinating schema changes across multiple application instances
When None, the ADK extension auto-detects the current schema version and applies any pending upgrades during initialization.
Notes
Schema versions are monotonically increasing integers managed by the ADK extension migration system. Setting this to a version lower than the current database schema will raise a configuration error at startup.
- Type:
Explicit schema version for ADK tables. Default
- partitioning: NotRequired[ADKPartitionConfig]¶
None (no partitioning).
Controls how ADK tables are partitioned for improved query performance and data management at scale. See
ADKPartitionConfigfor options.Supported by: PostgreSQL, MySQL 8+, Oracle, BigQuery, Spanner. Ignored by: SQLite, DuckDB.
- Type:
Table partitioning configuration. Default
- retention: NotRequired[ADKRetentionConfig]¶
None (no automatic cleanup).
Controls automatic expiry and cleanup of old session, event, and memory data. See
ADKRetentionConfigfor options.Backends with native TTL (CockroachDB, Spanner) use database-level enforcement. Others fall back to application-level sweep queries.
- Type:
Data retention and TTL configuration. Default
- compression: NotRequired[ADKCompressionConfig]¶
None (no compression).
Controls table-level compression for ADK tables. See
ADKCompressionConfigfor options.- Type:
Table compression configuration. Default
- sqlite_optimization: NotRequired[ADKSqliteOptimizationConfig]¶
None (SQLite defaults).
Controls SQLite performance tuning parameters. Ignored by non-SQLite adapters. See
ADKSqliteOptimizationConfigfor options.- Type:
SQLite-specific PRAGMA optimization settings. Default