Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/google/adk/plugins/context_filter_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
from typing import List
from typing import Optional

from google.genai import types

from ..agents.callback_context import CallbackContext
from ..events.event import Event
from ..models.llm_request import LlmRequest
from ..models.llm_response import LlmResponse
from .base_plugin import BasePlugin
Expand All @@ -34,7 +35,9 @@ class ContextFilterPlugin(BasePlugin):
def __init__(
self,
num_invocations_to_keep: Optional[int] = None,
custom_filter: Optional[Callable[[List[Event]], List[Event]]] = None,
custom_filter: Optional[
Callable[[List[types.Content]], List[types.Content]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with other parts of the codebase (e.g., llm_request.py which uses list[types.Content]) and to align with the PR description, it would be better to use the built-in list type hint instead of typing.List. This is the modern approach for Python 3.9+ and seems to be adopted in other files. Using list here would also allow for the removal of the from typing import List import, which would become unused.

Suggested change
Callable[[List[types.Content]], List[types.Content]]
Callable[[list[types.Content]], list[types.Content]]

] = None,
name: str = "context_filter_plugin",
):
"""Initializes the context management plugin.
Expand Down