Skip to content

Conversation

UlookEE
Copy link

@UlookEE UlookEE commented Oct 15, 2025

Fix #3163

Hello,
Since global_instruction has been deprecated, I’m migrating to GlobalInstructionPlugin.
During the migration, I encountered an error and am submitting this PR to fix it.

In df05ed6 ,
GlobalInstructionPlugin references invocation_context, but CallbackContext actually contains _invocation_context.
This mismatch always causes an error during execution.

@gemini-code-assist
Copy link

Summary of Changes

Hello @UlookEE, 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 within the GlobalInstructionPlugin that prevented proper context resolution. By adjusting an attribute access from invocation_context to _invocation_context, the change ensures that the plugin correctly initializes its ReadonlyContext, thereby eliminating errors that arose during the execution of global instructions, particularly for users migrating to the new plugin interface.

Highlights

  • Bug Fix: Corrected an error where the GlobalInstructionPlugin was attempting to access callback_context.invocation_context instead of the correct callback_context._invocation_context.
  • Context Resolution: Ensured that the ReadonlyContext is properly initialized with the internal _invocation_context attribute, resolving a mismatch that caused execution errors.
  • Migration Support: This fix addresses an issue encountered during the migration from the deprecated global_instruction to IGlobalInstructionPlugin, ensuring a smoother transition for users.
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 core [Component] This issue is related to the core interface and implementation label Oct 15, 2025
@adk-bot adk-bot requested a review from Jacksunwei October 15, 2025 13:21
@adk-bot
Copy link
Collaborator

adk-bot commented Oct 15, 2025

Response from ADK Triaging Agent

Hello @UlookEE, thank you for creating this PR!

Could you please add a testing plan section to your PR description to talk about how you tested this change? This will help reviewers to review your PR more efficiently. Thanks!

Copy link

@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 fixes a bug where GlobalInstructionPlugin was trying to access a non-existent invocation_context attribute on CallbackContext. The fix correctly uses _invocation_context instead. I've suggested a small refactoring to make the code cleaner by avoiding the creation of a redundant ReadonlyContext object and directly passing the callback_context, which also avoids accessing a private attribute.

@Jacksunwei Jacksunwei requested review from GWeale and removed request for Jacksunwei October 17, 2025 16:51
@UlookEE
Copy link
Author

UlookEE commented Oct 21, 2025

The previous test failure was caused by other commits. Please test it again.

@GWeale
Copy link
Collaborator

GWeale commented Oct 22, 2025

Hi thank you for this PR! df05ed6 this change has been rolled back, when this change gets added in I will merge this in as I think it is a great change!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError when using the GlobalInstructionPlugin with a Runner

3 participants