feat(sessions): Add session title management functionality
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
- Closes: #1825 #1340 #1372
- Related:
Problem: There is no title field in the sessions table, so when the frontend tries to display the chat history to users, there are no readable titles in the history list. In contrast, when users interact with other agents, the history list always contains readable titles.
Solution: This update introduces the ability to set, update, and clear titles for user sessions across various session services. The following changes were made:
- Added
titleattribute to theSessionmodel. - Implemented
update_session_titlemethod inBaseSessionServiceand its concrete implementations (e.g.,DatabaseSessionService,InMemorySessionService,SqliteSessionService,VertexAiSessionService). - Updated the
adk_web_server.pyto include a new endpoint for updating session titles. - Enhanced migration scripts to accommodate the new title field in session records.
- Added unit tests to verify the functionality of session title management.
Unit Tests
- [x] I have added or updated unit tests for this change.
- [x] All unit tests pass locally.
Manual End-to-End (E2E) Tests
I have installed the updated code on both my local machine and my server, started adk web, and run the agent. Everything works as expected with no issues.
Checklist
- [x] I have read the CONTRIBUTING.md document.
- [x] I have performed a self-review of my code.
- [x] I have added comments where the code may be difficult to understand.
- [x] I have added tests that prove my fix is effective or that my feature works.
- [x] All new and existing unit tests pass locally with my changes.
- [x] I have manually tested my changes end-to-end.
- [x] Any dependent changes have been merged and published in downstream modules.
Summary of Changes
Hello @zhangp365, 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 introduces a crucial feature for user experience by enabling the management of titles for user sessions. Previously, chat histories lacked readable titles, making it difficult for users to distinguish between different sessions. This change addresses that by integrating a title field into the session model and providing the necessary API and service layer functionality to set, update, and clear these titles, ensuring a consistent and user-friendly experience across all session types.
Highlights
- Session Model Enhancement: The
Sessionmodel now includes an optionaltitleattribute, allowing for human-readable names for user sessions. - API Endpoint for Title Management: A new PATCH endpoint
/apps/{app_name}/users/{user_id}/sessions/{session_id}/titlehas been added toadk_web_server.pyto enable updating session titles. - Service Layer Integration: The
update_session_titlemethod has been introduced inBaseSessionServiceand implemented across all concrete session service types (Database, In-Memory, SQLite, and Vertex AI) to support title creation, retrieval, and modification. - Database Schema Updates: Database-backed session services (Database and SQLite) have been updated to include a
titlecolumn in their respective session storage schemas, with migration scripts adjusted to handle this new field. - Comprehensive Unit Testing: Extensive unit tests have been added and updated to cover the new session title management functionality across all supported session service implementations, including edge cases like clearing titles and handling non-existent sessions.
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 @zhangp365 , Thank you for your work on this pull request. We appreciate the effort you've invested. Can you please fix the failing unit tests before we proceed with the review.
Hi @zhangp365 , Thank you for your work on this pull request. We appreciate the effort you've invested. Can you please fix the failing unit tests before we proceed with the review.
have fixed it.