Skip to content
13 changes: 13 additions & 0 deletions src/google/adk/plugins/logging_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from typing import TYPE_CHECKING

from google.genai import types
from typing_extensions import override

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

@override
async def on_user_message_callback(
self,
*,
Expand All @@ -87,6 +89,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 +102,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 +126,7 @@ async def on_event_callback(

return None

@override
async def after_run_callback(
self, *, invocation_context: InvocationContext
) -> Optional[None]:
Expand All @@ -134,6 +139,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 +151,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 +161,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 +187,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 +215,7 @@ async def after_model_callback(

return None

@override
async def before_tool_callback(
self,
*,
Expand All @@ -221,6 +231,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 +248,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 +263,7 @@ async def on_model_error_callback(

return None

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