Skip to content

Add database session service#129

Open
kalenkevich wants to merge 20 commits intomainfrom
feat/db_session_service
Open

Add database session service#129
kalenkevich wants to merge 20 commits intomainfrom
feat/db_session_service

Conversation

@kalenkevich
Copy link
Collaborator

@kalenkevich kalenkevich commented Feb 10, 2026

Description

This PR introduces the DatabaseSessionService, an implementation of the session service that uses a SQL database for persistence. This ensures that session state, user state, and application state are durable and can be shared across multiple instances of the application.

Key Changes

  • New Service: DatabaseSessionService extending BaseSessionService.
  • ORM Integration: Utilizes Sequelize to interact with the database, providing a type-safe and flexible data layer.
  • Data Models: Defines the following models for structured data storage:
    • StorageMetadata: For schema versioning and internal metadata.
    • StorageAppState: Stores application-level state (keyed by appName).
    • StorageUserState: Stores user-level state (keyed by appName + userId).
    • StorageSession: Stores session-specific state (keyed by sessionId).
    • StorageEvent: Stores events associated with sessions.

Supported Databases

Thanks to Sequelize, this service supports a wide range of SQL dialects. The implementation checks connection strings against the following supported protocols:

  • PostgreSQL
  • SQLite
  • MySQL
  • MariaDB
  • MSSQL

Implementation Details

  • Ensures Database prepared: Created database/tables in case they does not exists (Follows the Python ADK implementation).
  • Schema Validation: Includes a validateSchemaVersion check to ensure the database schema is compatible with the Python ADK DB session service.
  • State Management: Implements the standard ADK state merging logic, combining App, User, and Session states into a unified view for the agent.
  • Parity: Designed to maintain parity with the Python ADK's database session implementation. Stores the events in the snake_case format in the DB.

@kalenkevich kalenkevich marked this pull request as draft February 12, 2026 01:13
@kalenkevich kalenkevich force-pushed the feat/db_session_service branch from 3e02093 to e27d9ec Compare February 17, 2026 23:31
@kalenkevich kalenkevich force-pushed the feat/db_session_service branch from 8199939 to a81e60d Compare February 17, 2026 23:37
@kalenkevich kalenkevich marked this pull request as ready for review February 17, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants