Skip to content

Conversation

@Akshat8510
Copy link
Contributor

Description
This PR resolves #4100 by making the new_message field optional in the RunAgentRequest model.

The Problem:
When attempting to resume an agent session via the FastAPI web server, the request would fail with a 422 Unprocessable Entity if new_message was omitted. This prevented "resume-only" workflows where a user just wants to wake up an existing session.

The Solution:
Updated RunAgentRequest.new_message to be Optional[types.Content] = None. The underlying runner.run_async logic already supports None for resuming purposes, so no further logic changes were required.

Verification:
Verified that RunAgentRequest now validates successfully when new_message is missing, defaulting the field to None.

Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Akshat8510, 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 flexibility of agent session management by addressing a limitation in the RunAgentRequest model. Previously, resuming an agent session required a new_message field, even when no new input was intended. The change makes this field optional, aligning the web server's request handling with the underlying agent runner's capability to resume sessions with a None message. This modification streamlines the process for users who wish to simply reactivate an existing session.

Highlights

  • Optional Message Field: The new_message field in the RunAgentRequest model has been made optional, allowing agent sessions to be resumed without providing a new message.
  • Bug Fix: This change resolves an issue where attempting to resume an agent session via the FastAPI web server would result in a 422 Unprocessable Entity error if new_message was omitted.
  • Workflow Improvement: The update enables 'resume-only' workflows, where users can reactivate an existing session without needing to send new content.

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

@Akshat8510
Copy link
Contributor Author

@gemini-code-assist/gemini review

@adk-bot adk-bot added the web [Component] This issue will be transferred to adk-web label Jan 17, 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 correctly addresses the issue of being unable to resume an agent session without a new message. By changing RunAgentRequest.new_message to be optional (Optional[types.Content] = None), the API now properly supports "resume-only" workflows. The change is well-contained and aligns the web server's request model with the existing logic in runner.run_async, which already handles cases where new_message is None for session resumption. The implementation is correct. I have one suggestion to improve test coverage for this new capability.

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 correctly addresses the issue by making the new_message field optional in the RunAgentRequest model. This change allows for agent session resumption without requiring a new message, which is a valuable improvement for 'resume-only' workflows. The implementation is clean and direct. I've added one comment regarding the addition of a test case to ensure this fix is validated and to prevent future regressions.

…equests for session resumption without providing new content.

Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
@Akshat8510
Copy link
Contributor Author

@gemini-code-assist/gemini review

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 correctly makes the new_message field optional in RunAgentRequest to resolve a 422 Unprocessable Entity error when resuming a session. The inclusion of a new unit test to verify this is a good practice. However, the fix is incomplete as it introduces a new runtime error. The new test provides a false positive because it mocks the Runner.run_async method, bypassing a validation check that would cause a ValueError and a 500 error in a real-world scenario. To be complete, the runner logic should also be updated to handle this new 'resume-only' case gracefully.

Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
@Akshat8510
Copy link
Contributor Author

@gemini-code-assist/gemini review

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 correctly addresses the issue of allowing agent session resumption without requiring a new_message. The change to make RunAgentRequest.new_message optional is well-implemented. The corresponding adjustment in runners.py to handle a "no-op resume" by returning early instead of raising an error is a sensible approach. The new test case effectively verifies that the API now accepts requests without a new message. I have a couple of minor suggestions in the test file to improve code cleanliness.

Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
@Akshat8510
Copy link
Contributor Author

@gemini-code-assist/gemini review

@Akshat8510
Copy link
Contributor Author

/gemini summary

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 correctly makes the new_message field optional in RunAgentRequest to support 'resume-only' workflows, which is a good enhancement. The changes in the web server model, the runner logic, and the addition of a new test case are all well-aligned with this goal. I have one suggestion to improve observability for the new no-op resume behavior.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

This pull request enhances the flexibility of agent session management by enabling "resume-only" workflows. It addresses a previous limitation where the FastAPI web server would reject requests to resume an agent session if no new_message was provided. The changes involve making the new_message field optional in the request model and updating the underlying runner logic to correctly process such requests as a no-op resume, ensuring a smoother user experience for reactivating existing sessions.

Highlights

  • Optional Message Field: The new_message field in the RunAgentRequest model has been made optional, allowing agent sessions to be resumed without providing new content.
  • Graceful No-Op Resume: The agent runner logic was modified to gracefully handle 'resume-only' requests where neither a new message nor an invocation ID is provided, preventing ValueError and performing a no-op resume.
  • New Test Coverage: A new test case was added to test_fast_api.py to validate the successful handling of agent session resume requests without a new message.

🧠 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
  • src/google/adk/cli/adk_web_server.py
    • The new_message field in the RunAgentRequest model is now Optional[types.Content] = None, making it optional for incoming requests.
  • src/google/adk/runners.py
    • The _run_with_trace function now explicitly handles cases where neither invocation_id nor new_message is provided by performing a no-op resume and returning early, instead of raising a ValueError.
  • tests/unittests/cli/test_fast_api.py
    • A new test, test_agent_run_resume_without_message, has been added to verify that the /run endpoint correctly processes agent session resume requests when new_message is omitted.
Activity
  • gemini-code-assist[bot] provided an initial summary of the pull request.
  • gemini-code-assist[bot] suggested adding test cases to verify the optional new_message field and prevent regressions.
  • gemini-code-assist[bot] identified an issue with the initial test's mocking strategy and recommended updating the runner logic to properly handle "resume-only" scenarios.
  • gemini-code-assist[bot] provided minor suggestions for code readability and test hygiene (removing blank lines, unnecessary logging).
  • gemini-code-assist[bot] suggested adding a log message for the no-op resume in the runner for better observability.
  • The author, Akshat8510, repeatedly requested reviews and summaries from the bot.

Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
@Akshat8510
Copy link
Contributor Author

@gemini-code-assist/gemini review

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 correctly makes the new_message field optional in the RunAgentRequest to allow for "resume-only" workflows, which is a great enhancement. The changes are well-implemented, including the logic to handle this case as a no-op in the runner and the addition of a new test case.

I have a couple of suggestions to further improve the changes:

  • Update the run_async docstring to reflect the new behavior.
  • Enhance the new test to cover the full end-to-end logic instead of mocking the runner's behavior.

Overall, this is a solid contribution.

Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
@Akshat8510
Copy link
Contributor Author

@gemini-code-assist/gemini review

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 correctly addresses the issue of allowing session resumption without a new message by making the new_message field optional. The changes to the RunAgentRequest model and the corresponding logic in runners.py are appropriate and well-implemented. The addition of a new test case to verify this behavior is also a great inclusion. I have a couple of minor suggestions to improve the clarity of the documentation and a test comment.

Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
@Akshat8510
Copy link
Contributor Author

@gemini-code-assist/gemini review

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 resolves an issue where resuming an agent session without a new message would fail. The changes make the new_message field in RunAgentRequest optional and update the runner logic to handle this case as a no-op resume, which is a clean solution. The docstrings have been updated to reflect the new behavior, and a new test case has been added to verify the fix. The changes are well-implemented and improve the flexibility of the web API. The code quality is high, and I have no further suggestions for improvement.

@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

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

Labels

web [Component] This issue will be transferred to adk-web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impossible to resume agents throught fastapi endpoint without "new_message"

2 participants