Skip to content

Comments

feat: add @override decorators to LoggingPlugin callback methods (#4496)#4572

Open
cchinchilla-dev wants to merge 4 commits intogoogle:mainfrom
cchinchilla-dev:feat/add_override_decorators_to_loggingplugin_4496
Open

feat: add @override decorators to LoggingPlugin callback methods (#4496)#4572
cchinchilla-dev wants to merge 4 commits intogoogle:mainfrom
cchinchilla-dev:feat/add_override_decorators_to_loggingplugin_4496

Conversation

@cchinchilla-dev
Copy link

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:

LoggingPlugin overrides 12 callback methods from BasePlugin but none use the @override decorator. Every other plugin in the package (DebugLoggingPlugin, ReplayPlugin, RecordingsPlugin, EnsureRetryOptionsPlugin, _RequestIntercepterPlugin) already follows this practice. With mypy --strict enabled in pyproject.toml, missing @override means renamed or removed base-class methods would be silently missed in LoggingPlugin while being caught everywhere else.

Solution:

Import override from typing_extensions and decorate all 12 overridden callbacks. Purely additive: one import line and 12 decorators. No behavioral, API, or runtime change.

Testing Plan

Unit Tests:

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

No new tests are required — @override is a static-analysis-only decorator with no runtime effect. Ran mypy on the file before and after the change: same preexisting warnings, no new errors introduced. CI will validate via the existing test suite and linting checks.

Manual End-to-End (E2E) Tests:

Not applicable. This change adds only decorators with no runtime behavior. Verified by comparing mypy output before and after — no new errors.

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

I am the author of the original issue (#4496). A previous PR (#4544) was opened but is pending clarification, so I'm
submitting this complete PR as the original issue author.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @cchinchilla-dev, 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 focuses on improving the static analysis capabilities of the LoggingPlugin by systematically applying @override decorators to its callback methods. This change brings the LoggingPlugin into alignment with established practices within the package, where other plugins already leverage these decorators for enhanced type checking. The primary benefit is to prevent silent failures if base-class methods are renamed or removed, without introducing any runtime changes or altering the plugin's behavior.

Highlights

  • Static Analysis Improvement: Added @override decorators to all 12 callback methods within the LoggingPlugin class. This enhances static analysis, ensuring that method signature mismatches with the base class are caught during type checking.
  • Consistency Across Plugins: Aligned LoggingPlugin with other plugins in the package (e.g., DebugLoggingPlugin, ReplayPlugin) that already utilize @override decorators, promoting consistent code quality and maintainability.
  • No Runtime Impact: The changes are purely additive and static-analysis-only, introducing no behavioral, API, or runtime modifications to the LoggingPlugin.

🧠 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/plugins/logging_plugin.py
    • Imported the override decorator from typing_extensions.
    • Added the @override decorator to 12 callback methods, including on_user_message_callback, before_run_callback, on_event_callback, after_run_callback, before_agent_callback, after_agent_callback, before_model_callback, after_model_callback, before_tool_callback, after_tool_callback, on_model_error_callback, and on_tool_error_callback.
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 adds @override decorators to the callback methods in LoggingPlugin that override methods from BasePlugin. This is a great improvement for static analysis and code maintainability, ensuring that any future changes to the base class methods are caught by tools like mypy. The changes are correct and well-implemented. No issues found.

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Feb 20, 2026
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.

feat(plugins): add missing @override decorators to LoggingPlugin callback methods

2 participants