Skip to content

Implement Database-Backed Session Storage (DatabaseSessionService) for ADK Java #665

@prasadskarmarkar

Description

@prasadskarmarkar

Is your feature request related to a problem? Please describe.
ADK Java currently provides only in-memory session storage, which is not suitable for production environments that require durable, consistent, and queryable session/state/event storage.

Projects building on ADK often need:

  • Persistent session storage across restarts
  • Reliable event logging and retrieval
  • Concurrency-safe updates
  • Support for standard relational databases
  • Schema versioning for continuous delivery

Describe the solution you'd like
Introduce a production-ready database-backed session service (DatabaseSessionService) that provides durable storage for sessions, events, and state.

Key characteristics:

  • Hibernate 6.6 ORM integration
  • HikariCP connection pooling
  • Flyway migrations for schema versioning and zero-downtime deployments
  • Support for PostgreSQL, MySQL, H2, and other RDBMS
  • Pessimistic locking for safe concurrent updates
  • Dialect-aware JSON handling (JSONB for PostgreSQL, CLOB for others)
  • Event filtering and pagination
  • Comprehensive test coverage using H2 and Integration tests to test all the features on actual database running in docker.

This service would offer a robust, scalable alternative to the current in-memory session implementation.

Describe alternatives you've considered

  1. Providing this as an external extension/library

    • Persistent sessions are commonly required; shipping this in-core provides a better out-of-the-box experience.
  2. Continuing with in-memory storage only

    • Not viable for production deployments requiring durability or concurrency guarantees.

Additional context
The Python ADK includes a production-grade DatabaseSessionService that is widely used in real-world workloads (including GKE deployments). Adding equivalent persistent session storage to ADK Java would provide consistency across ADK environments and reduce the need for custom user-built solutions.

An implementation is available in PR : #654

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions