feat: Add DatabaseSessionService with JDBC and Flyway support
fixes #665
Summary Implements a production-ready database-backed session service that provides persistent storage for ADK sessions, events, and state using JDBC.
Key Features
- JDBC with HikariCP connection pooling for optimal performance
- Flyway migrations for schema versioning and zero-downtime deployments
- Multi-database support: PostgreSQL, MySQL, H2, Cloud Spanner, and other RDBMS
- Thread-safe operations with pessimistic locking for concurrent updates
- Comprehensive test coverage with H2 in-memory database and Integration tests for PostgreSQL , MySQL and Spanner ( using emulator ) .
- Dialect-aware JSON storage (JSONB for PostgreSQL, CLOB for others)
- Event filtering and pagination for efficient data retrieval
Architecture
-
Located in contrib/database-session-service module
-
Minimal core dependencies footprint
-
Users explicitly opt-in via dependency
-
Follows existing contrib pattern
Tasks
- [x] Implement DatabaseSessionService with JDBC (no ORM dependencies)
- [x] Add multi-database support (PostgreSQL, MySQL, H2, Spanner)
- [x] Implement 3-tier state storage (app/user/session levels)
- [x] Add Flyway migrations for schema management
- [x] Add comprehensive test suite (unit + integration tests)
- [x] Add documentation and usage examples
- [x] Address code review feedback
Summary of Changes
Hello @prasadskarmarkar, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request delivers a robust DatabaseSessionService for the Agent Development Kit (ADK) Java, providing persistent session management capabilities. It utilizes standard JDBC with HikariCP for efficient connection pooling and Flyway for seamless schema migrations across multiple database systems like PostgreSQL, MySQL, H2, and Cloud Spanner. The service features a sophisticated 3-tier state management system and ensures data integrity through thread-safe, pessimistic locking. Accompanying tutorials illustrate its practical application in various agent workflows, making it easier for developers to integrate persistent state into their ADK agents.
Highlights
- New Database Session Service: Introduces a production-ready, database-backed session service for ADK Java, enabling persistent storage for sessions, events, and state.
- JDBC with HikariCP and Flyway: The service leverages pure JDBC with HikariCP for high-performance connection pooling and Flyway for automatic, versioned database schema migrations.
- Multi-Database Support: It supports a variety of relational databases including PostgreSQL, MySQL, H2, and Cloud Spanner, with dialect-aware JSON storage.
- 3-Tier State Management: Implements a flexible 3-tier state storage model (app-level, user-level, session-level) with defined merging priorities.
- Thread-Safe Operations: Ensures thread-safe operations through connection pooling, database transactions, and pessimistic locking for concurrent updates.
- Comprehensive Tutorials: New tutorials demonstrate the service's integration with sequential, loop, and custom tool agent patterns, showcasing session persistence and state sharing.
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.
Hi ,
this PR addresses #665.
Could someone please review it when convenient?
Happy to make any changes based on feedback. Thanks!
+1
Hi team — just checking in on this PR when you have a chance.
I’d appreciate a review whenever you have bandwidth and am happy to address any feedback.
Also, I’m working on updating related tutorials and documentation so this can be reflected in the official adk-java docs once merged.
Thanks!
Just mentioning that I would also like to see this
Hi team — just checking in on this PR when you have a chance.
I’d appreciate a review whenever you have bandwidth and am happy to address any feedback.
Also, I’m working on updating related tutorials and documentation so this can be reflected in the official adk-java docs once merged.
Thanks!
Seconding that I would also like to see this soon - I've forked this and added it to a project I work on and have been using it extensively for maybe a month now. I haven't encountered any bugs yet. It saved me a lot of time, and hopefully save others more time in the future.
Thanks for that implementaiton @prasadskarmarkar! Seconding that feature too! In adk-java I think this is a second highest missing feature after evaluations. Curious if the ADK team has that on a radar anytime soon :) Thanks!
Hi @prasadskarmarkar, Thank you for your contribution! We appreciate you taking the time to submit this pull request. I have observed that this branch as conflicts. could you please resolve them?
@hemasekhar-p - merge conflicts are resolved now.