Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Public Invocation Context for Global Instructions Plugin #3216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
juanfcastropiccolo wants to merge 4 commits into google:main
base: main
Choose a base branch
Loading
from juanfcastropiccolo:feature/CallbackContext_public_InvocationContext

Conversation

@juanfcastropiccolo
Copy link

@juanfcastropiccolo juanfcastropiccolo commented Oct 18, 2025
edited
Loading

Summary

This PR addresses the TODO comment in CallbackContext.__init__ by exposing the invocation_context as a public property for Agent Development Kit plugin use.

Problem

The GlobalInstructionPlugin and potentially other ADK plugins need access to the invocation_context to create ReadonlyContext instances. Currently, only the private _invocation_context attribute is available, causing AttributeError when plugins attempt to access callback_context.invocation_context.

Solution

Added a public @property method invocation_context() to the CallbackContext class that returns self._invocation_context. This follows the same pattern used for other context properties like state and session.

Changes

  • Added invocation_context property to CallbackContext class
  • Added comprehensive docstring explaining this if for ADK plugin development
  • Mantains backward compatibility (no breaking changes)

Testing

  • Verified that GlobalInstructionPlugin.before_model_callback now works correctly
  • No linting errors
  • Follows existing code style and patterns in the codebase

Related

Resolves the TODO: "make this public for Agent Development Kit, but private for users."

Copy link

google-cla bot commented Oct 18, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link

Summary of Changes

Hello @juanfcastropiccolo, 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 introduces a public invocation_context property to the CallbackContext class, enabling Agent Development Kit (ADK) plugins to access the underlying invocation context. This modification directly addresses a problem where ADK plugins, like the GlobalInstructionPlugin, required this context but could only access a private attribute, leading to runtime errors. The change ensures proper functionality for ADK plugin development while maintaining backward compatibility and adhering to established coding patterns.

Highlights

  • Public Invocation Context: The invocation_context is now exposed as a public property within the CallbackContext class, specifically for use by Agent Development Kit (ADK) plugins.
  • Resolves AttributeError: This change resolves an AttributeError encountered by ADK plugins, such as GlobalInstructionPlugin, when attempting to access the previously private _invocation_context.
  • Addresses TODO Comment: A long-standing TODO comment in CallbackContext.__init__ regarding making the invocation context public for ADK development has been addressed.
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

@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 exposes the invocation_context as a public property on CallbackContext to be used by ADK plugins, resolving a TODO item. The implementation is straightforward and follows existing patterns in the codebase. I have one suggestion to improve the docstring for this new property by removing an implementation note to make it cleaner for public consumption.

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Oct 18, 2025
Copy link
Collaborator

adk-bot commented Oct 18, 2025

Response from ADK Triaging Agent

Hello @juanfcastropiccolo, thank you for creating this PR!

To help us review this PR, could you please create and associate a GitHub issue with this PR?

In addition, could you please expand on the testing plan and provide logs or a screenshot demonstrating the fix?

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

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

Reviewers

@Jacksunwei Jacksunwei Awaiting requested review from Jacksunwei

1 more reviewer

@gemini-code-assist gemini-code-assist[bot] gemini-code-assist[bot] left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /