-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feature/auto-create-new-session #4072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feature/auto-create-new-session #4072
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @lwangverizon, I'm Gemini Code Assist1! 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 enhances the Highlights
🧠 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 AssistThe 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
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 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 👍 and 👎 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. Footnotes
|
|
Response from ADK Triaging Agent Hello @lwangverizon, thank you for your contribution! Before we can review your PR, you will need to sign the Contributor License Agreement (CLA). It looks like the CLA check is currently failing. Please visit https://cla.developers.google.com/ to sign the agreement. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a "get or create" pattern for get_session, which is a useful feature. However, the current implementation in DatabaseSessionService is inefficient, as it creates a session and then immediately re-fetches it, leading to redundant database calls. A more efficient approach would be to return the result of create_session directly. Furthermore, this change introduces a behavioral inconsistency: get_session will now always return a Session for DatabaseSessionService, while the base class and other implementations still allow for a None return. This should be addressed by either making the behavior consistent across all implementations and updating the base class contract, or by introducing a new method for this functionality. The unit tests also need to be updated to reflect this new behavior, as some will likely fail.
|
Hi @lwangverizon, Thank you for your contribution! We appreciate you taking the time to submit this pull request. |
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
2. Or, if no issue exists, describe the change:
Problem:
When building frontend applications with ADK, there's a limitation where frontends cannot always guarantee that
create_sessionis called before initiating a conversation. This creates friction in the user experience because:create_sessionis called first adds unnecessary complexityCurrently, if
get_sessionis called with a non-existent session_id, it returnsNone, requiring the frontend to explicitly handle this case and callcreate_sessionseparately.Solution:
Modified the
get_sessionmethod inDatabaseSessionServiceto automatically create a session if it doesn't exist in the database. This "get or create" pattern is common in many frameworks and provides a more developer-friendly API.The implementation:
None), automatically callscreate_sessionwith the provided parametersThis allows frontends to simply call
get_sessionwith a session_id and be confident that the session will be available, regardless of whether it was previously created.Benefits:
Nonereturn valuesTesting Plan
Unit Tests:
pytest results: