Skip to content

fix: correct include_contents behavior in ADK web (fixes google#3535)#4492

Open
dalagadenilesh wants to merge 2 commits intogoogle:mainfrom
dalagadenilesh:fix/include_contant_to_none
Open

fix: correct include_contents behavior in ADK web (fixes google#3535)#4492
dalagadenilesh wants to merge 2 commits intogoogle:mainfrom
dalagadenilesh:fix/include_contant_to_none

Conversation

@dalagadenilesh
Copy link

@dalagadenilesh dalagadenilesh commented Feb 14, 2026

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:

Problem:

The issue is that if a sub-agent is transferred to take over control, the context should include the user input. But the actual context for this sub-agent doesn't contain the latest user input, but the last transfer_to_agent context from the parent agent.

Solution:
Solution is to avoid adding events with either transfer_to_agent exits or name of the agent function call is 'transfer_to_agent'

Testing Plan

N/A

Unit Tests:

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

Please include a summary of passed pytest results.

Manual End-to-End (E2E) Tests:

Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix.

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

Add any other context or screenshots about the feature request here.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @dalagadenilesh, 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 resolves a critical bug in the ADK web application where the conversational context provided to a sub-agent after a transfer was incorrect, specifically lacking the most recent user input. The changes ensure that when control is passed to a sub-agent, its operational context is properly updated with the latest user interaction, thereby improving the accuracy and relevance of its responses.

Highlights

  • Context Correction for Sub-Agents: Addressed an issue where sub-agents, after a transfer of control, were not receiving the latest user input in their context. Previously, the context would contain the transfer_to_agent context from the parent agent, leading to stale information.
  • Exclusion of Transfer Events: Implemented a solution to prevent events related to transfer_to_agent exits or function calls from being included in the sub-agent's context. This ensures that the context accurately reflects the current user interaction.
  • New Helper Function: Introduced a new helper function, _is_direct_transfer, to reliably identify events that signify a direct agent transfer, facilitating their exclusion from the context generation process.

🧠 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/flows/llm_flows/contents.py
    • Modified the _get_current_turn_contents function to incorporate a new condition that excludes direct agent transfer events when determining the current turn's contents.
    • Added a new private helper function _is_direct_transfer to check if an event represents a direct transfer, either through event.actions.transfer_to_agent or a transfer_to_agent function call within event content parts.
Activity
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 aims to fix an issue where a sub-agent receives an incorrect context upon transfer. The proposed solution is to filter out 'transfer_to_agent' events when constructing the context for the current turn. The changes look good and align with the problem description. I've found one potential AttributeError in the new _is_direct_transfer function and suggested a fix. Please see the detailed comment. It would also be beneficial to add unit tests for the new _is_direct_transfer function to cover its logic and edge cases, such as when an event's content is None.

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Feb 14, 2026
@adk-bot
Copy link
Collaborator

adk-bot commented Feb 14, 2026

Response from ADK Triaging Agent

Hello @dalagadenilesh, thank you for creating this PR!

Could you please provide a testing plan and include logs or screenshots from your manual end-to-end testing? This information will help reviewers to review your PR more efficiently. Thanks!

@adk-bot adk-bot added the web [Component] This issue will be transferred to adk-web label Feb 14, 2026
@adk-bot
Copy link
Collaborator

adk-bot commented Feb 14, 2026

Response from ADK Triaging Agent

Hello @dalagadenilesh, thank you for creating this PR!

I've noticed a few things are missing from the PR description:

  • Could you please provide a testing plan to describe how you tested your changes?
  • Could you please provide a summary of the passed pytest results for the unit tests?
  • Could you please provide logs or screenshots for the manual end-to-end tests to help reviewers better understand the fix?

This information will help reviewers to review your PR more efficiently. Thanks!

@adk-bot
Copy link
Collaborator

adk-bot commented Feb 14, 2026

Response from ADK Triaging Agent

Hello @dalagadenilesh, thank you for your contribution!

To help us review this PR, could you please provide a more detailed testing plan?

According to our contribution guidelines, we require the following for bug fixes:

  • Unit Tests: Please add or update unit tests for your change and confirm that all tests pass locally.
  • Manual End-to-End (E2E) Tests: Please provide instructions on how to manually test your changes, along with logs or screenshots to demonstrate the fix.

You can find more details in our contribution guidelines. This information will help reviewers to verify the fix and review your PR more efficiently. Thanks!

@adk-bot
Copy link
Collaborator

adk-bot commented Feb 14, 2026

Response from ADK Triaging Agent

Hello @dalagadenilesh, thank you for your contribution!

To help us review this bug fix, could you please provide a more detailed 'Testing Plan'? Specifically, we need the instructions for manual End-to-End (E2E) tests and any relevant logs or screenshots that demonstrate the fix is working as expected.

This information is crucial for our review process as outlined in the contribution guidelines. Thanks!

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

Labels

core [Component] This issue is related to the core interface and implementation web [Component] This issue will be transferred to adk-web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants