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
14 changes: 14 additions & 0 deletions src/google/adk/plugins/logging_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from typing import Optional
from typing import TYPE_CHECKING

from typing_extensions import override

from google.genai import types

from ..agents.base_agent import BaseAgent
Expand Down Expand Up @@ -66,6 +68,7 @@ def __init__(self, name: str = "logging_plugin"):
"""
super().__init__(name)

@override
async def on_user_message_callback(
self,
*,
Expand All @@ -87,6 +90,7 @@ async def on_user_message_callback(
self._log(f" Branch: {invocation_context.branch}")
return None

@override
async def before_run_callback(
self, *, invocation_context: InvocationContext
) -> Optional[types.Content]:
Expand All @@ -99,6 +103,7 @@ async def before_run_callback(
)
return None

@override
async def on_event_callback(
self, *, invocation_context: InvocationContext, event: Event
) -> Optional[Event]:
Expand All @@ -122,6 +127,7 @@ async def on_event_callback(

return None

@override
async def after_run_callback(
self, *, invocation_context: InvocationContext
) -> Optional[None]:
Expand All @@ -134,6 +140,7 @@ async def after_run_callback(
)
return None

@override
async def before_agent_callback(
self, *, agent: BaseAgent, callback_context: CallbackContext
) -> Optional[types.Content]:
Expand All @@ -145,6 +152,7 @@ async def before_agent_callback(
self._log(f" Branch: {callback_context._invocation_context.branch}")
return None

@override
async def after_agent_callback(
self, *, agent: BaseAgent, callback_context: CallbackContext
) -> Optional[types.Content]:
Expand All @@ -154,6 +162,7 @@ async def after_agent_callback(
self._log(f" Invocation ID: {callback_context.invocation_id}")
return None

@override
async def before_model_callback(
self, *, callback_context: CallbackContext, llm_request: LlmRequest
) -> Optional[LlmResponse]:
Expand All @@ -179,6 +188,7 @@ async def before_model_callback(

return None

@override
async def after_model_callback(
self, *, callback_context: CallbackContext, llm_response: LlmResponse
) -> Optional[LlmResponse]:
Expand Down Expand Up @@ -206,6 +216,7 @@ async def after_model_callback(

return None

@override
async def before_tool_callback(
self,
*,
Expand All @@ -221,6 +232,7 @@ async def before_tool_callback(
self._log(f" Arguments: {self._format_args(tool_args)}")
return None

@override
async def after_tool_callback(
self,
*,
Expand All @@ -237,6 +249,7 @@ async def after_tool_callback(
self._log(f" Result: {self._format_args(result)}")
return None

@override
async def on_model_error_callback(
self,
*,
Expand All @@ -251,6 +264,7 @@ async def on_model_error_callback(

return None

@override
async def on_tool_error_callback(
self,
*,
Expand Down