From 6595cda037c1fc16ac447e5aaaf1f55af929b99a Mon Sep 17 00:00:00 2001 From: "Wei Sun (Jack)" Date: Fri, 2 May 2025 18:57:15 -0700 Subject: [PATCH] Update description of before/after_agent_callback to clarify the behavior. PiperOrigin-RevId: 754207459 --- src/google/adk/agents/base_agent.py | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/google/adk/agents/base_agent.py b/src/google/adk/agents/base_agent.py index 0bec85f..764fedb 100644 --- a/src/google/adk/agents/base_agent.py +++ b/src/google/adk/agents/base_agent.py @@ -38,26 +38,9 @@ if TYPE_CHECKING: tracer = trace.get_tracer('gcp.vertex.agent') BeforeAgentCallback = Callable[[CallbackContext], Optional[types.Content]] -"""Callback signature that is invoked before the agent run. -Args: - callback_context: MUST be named 'callback_context' (enforced). - -Returns: - The content to return to the user. When set, the agent run will be skipped and - the provided content will be returned to user. -""" AfterAgentCallback = Callable[[CallbackContext], Optional[types.Content]] -"""Callback signature that is invoked after the agent run. - -Args: - callback_context: MUST be named 'callback_context' (enforced). - -Returns: - The content to return to the user. When set, the provided content will be - appended to event history as agent response. -""" class BaseAgent(BaseModel): @@ -101,8 +84,9 @@ class BaseAgent(BaseModel): callback_context: MUST be named 'callback_context' (enforced). Returns: - The content to return to the user. When set, the agent run will be skipped - and the provided content will be returned to user. + Optional[types.Content]: The content to return to the user. + When the content is present, the agent run will be skipped and the + provided content will be returned to user. """ after_agent_callback: Optional[AfterAgentCallback] = None """Callback signature that is invoked after the agent run. @@ -111,8 +95,9 @@ class BaseAgent(BaseModel): callback_context: MUST be named 'callback_context' (enforced). Returns: - The content to return to the user. When set, the provided content will be - appended to event history as agent response. + Optional[types.Content]: The content to return to the user. + When the content is present, the provided content will be used as agent + response and appended to event history as agent response. """ @final