Skip to content

feat: allow the runner to automatically create a session if AutoCreateSession is enabled.#622

Merged
hanorik merged 7 commits intogoogle:mainfrom
hanorik:auto_create_session
Mar 20, 2026
Merged

feat: allow the runner to automatically create a session if AutoCreateSession is enabled.#622
hanorik merged 7 commits intogoogle:mainfrom
hanorik:auto_create_session

Conversation

@hanorik
Copy link
Contributor

@hanorik hanorik commented Mar 5, 2026

This change introduces an AutoCreateSession configuration option to the Runner. When enabled, the Runner.Run method will automatically create a new session if the requested session ID is not found, instead of returning an error. This aligns the behavior with the Python ADK. Also added TestRunner_AutoCreateSession test to verify expected behavior across four scenarios.

@hanorik hanorik requested review from baptmont and dpasiukevich March 5, 2026 16:06
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 Runner's session management by introducing an AutoCreateSession configuration. When enabled, the Runner.Run method will now automatically provision a new session if the specified session ID does not exist, rather than returning an error. This change aligns the Runner's behavior with the existing Python ADK, improving consistency and user experience by reducing boilerplate for session initialization.

Highlights

  • New Configuration Option: Introduced an AutoCreateSession boolean field to the runner.Config struct, allowing users to configure automatic session creation.
  • Automatic Session Creation Logic: Implemented logic within the Runner.Run method to automatically create a new session if AutoCreateSession is enabled and the requested session ID is not found, aligning behavior with the Python ADK.
  • Comprehensive Testing: Added a new test suite, TestRunner_AutoCreateSession, which covers four distinct scenarios to thoroughly validate the new automatic session creation functionality.

🧠 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.

Changelog
  • runner/runner.go
    • Added AutoCreateSession boolean field to Config struct.
    • Initialized autoCreateSession field in New function.
    • Added autoCreateSession boolean field to Runner struct.
    • Modified Run method to check autoCreateSession and create a new session if Get fails and the option is enabled.
  • runner/runner_test.go
    • Added TestRunner_AutoCreateSession function to test the AutoCreateSession functionality with four distinct test cases.
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 👍 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

  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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 an AutoCreateSession option to the Runner. The implementation correctly adds the configuration and a new field to the Runner struct. The core logic in Runner.Run is updated to create a session if it doesn't exist when this option is enabled. The accompanying test TestRunner_AutoCreateSession is well-written and covers the expected scenarios.

I have two points of feedback. First, a minor style inconsistency in a comment. Second, and more importantly, a potential issue in the error handling logic for session creation. The current implementation could attempt to create a session on any error from sessionService.Get, not just when a session is not found, which could mask other problems. Please see my detailed comments.

hanorik and others added 2 commits March 5, 2026 18:05
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@hanorik hanorik requested a review from mazas-google March 6, 2026 13:21
@hanorik hanorik merged commit 9f0d476 into google:main Mar 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants