Skip to content

Conversation

@ekimcodes
Copy link

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

N/A - Issue exists

Testing Plan

Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

$ pytest tests/unittests/cli/ -v

============================= test session starts ==============================
platform darwin -- Python 3.11.14, pytest-9.0.2, pluggy-1.6.0
collected 246 items
...
====================== 246 passed, 147 warnings in 21.38s ======================

Manual End-to-End (E2E) Tests:

  1. Verify CLI flag is recognized:
    $ adk api_server --help | grep auto_create_session --auto_create_session
    Automatically create a session if it doesn't exist when calling /run.

  2. Start server with flag enabled:
    $ adk api_server --auto_create_session

  3. Test /run endpoint without pre-creating session:
    $ curl -X POST http://localhost:8000/run
    -H "Content-Type: application/json"
    -d '{"app_name": "my_agent", "user_id": "user1", "session_id": "new_session", "new_message": {"role": "user", "parts": [{"text": "Hello"}]}}'

Expected: Session auto-created, request succeeds (no 404 error).

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

This PR exposes the existing Runner.auto_create_session functionality (added in commit 8e69a58 / ADK v1.23.0) through the adk api_server CLI command.

Files changed (3 files, ~15 lines):

src/google/adk/cli/cli_tools_click.py - Add --auto_create_session CLI option
src/google/adk/cli/fast_api.py - Pass parameter through get_fast_api_app()
src/google/adk/cli/adk_web_server.py - Store and use in _create_runner()

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ekimcodes, 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 adk api_server functionality by introducing a command-line option to enable automatic session creation. This change streamlines the interaction with the /run endpoint, preventing 404 errors when a session ID is provided but the session does not yet exist. Additionally, it includes updates to deprecate older evaluation API endpoints, guiding users towards more current and standardized methods.

Highlights

  • CLI Option for Auto Session Creation: A new --auto_create_session flag has been added to the adk api_server CLI command. This flag allows the API server to automatically create a session if one does not exist when the /run endpoint is called.
  • Integration of Auto Session Creation: The auto_create_session parameter is now propagated through the get_fast_api_app function to the AdkWebServer constructor, and subsequently passed to the Runner instance during its creation. This ensures the CLI flag effectively controls the Runner's behavior.
  • Deprecation of Legacy Evaluation Endpoints: Several legacy evaluation-related FastAPI endpoints (e.g., create_eval_set_legacy, list_eval_sets_legacy, run_eval_legacy, get_eval_result_legacy, list_eval_results_legacy) have been marked as deprecated. These endpoints now wrap their newer counterparts and will be removed in future releases.

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

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Jan 27, 2026
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 two main changes. First, it correctly exposes the auto_create_session functionality of the Runner class as a --auto_create_session flag in the adk api_server command. This is a useful feature that allows for automatic session creation if one does not exist. The change is implemented correctly by passing the parameter through cli_tools_click.py, fast_api.py, and adk_web_server.py. Second, it adds several deprecated legacy API endpoints for evaluation functionalities to ensure backward compatibility. These legacy endpoints use underscores in their paths (e.g., /eval_sets) to differentiate from the newer endpoints that use hyphens (e.g., /eval-sets). The implementation of both changes appears correct and well-executed. It would be beneficial to update the pull request description to also mention the addition of the legacy endpoints for clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add --auto_create_session flag to adk api_server CLI

2 participants