@@ -111,125 +111,81 @@ def __init__(self, name: str):
111111 super ().__init__ ()
112112 self .name = name
113113
114- if TYPE_CHECKING :
115-
116- async def on_user_message_callback (
117- self ,
118- * ,
119- callback_context : Optional [CallbackContext ] = None ,
120- user_message : types .Content ,
121- invocation_context : Optional [InvocationContext ] = None ,
122- ) -> Optional [types .Content ]:
123- """Callback executed when a user message is received before an invocation starts.
124-
125- Plugins can implement this with either callback_context (new) or
126- invocation_context (deprecated) or both.
127- """
128-
129- async def before_run_callback (
130- self ,
131- * ,
132- callback_context : Optional [CallbackContext ] = None ,
133- invocation_context : Optional [InvocationContext ] = None ,
134- ) -> Optional [types .Content ]:
135- """Callback executed before the ADK runner runs.
136-
137- Plugins can implement this with either callback_context (new) or
138- invocation_context (deprecated) or both.
139- """
140-
141- async def on_event_callback (
142- self ,
143- * ,
144- callback_context : Optional [CallbackContext ] = None ,
145- event : Event ,
146- invocation_context : Optional [InvocationContext ] = None ,
147- ) -> Optional [Event ]:
148- """Callback executed after an event is yielded from runner.
149-
150- Plugins can implement this with either callback_context (new) or
151- invocation_context (deprecated) or both.
152- """
153-
154- async def after_run_callback (
155- self ,
156- * ,
157- callback_context : Optional [CallbackContext ] = None ,
158- invocation_context : Optional [InvocationContext ] = None ,
159- ) -> None :
160- """Callback executed after an ADK runner run has completed.
161-
162- Plugins can implement this with either callback_context (new) or
163- invocation_context (deprecated) or both.
164- """
165-
166- # Runtime implementation accepts both via **kwargs
167114 async def on_user_message_callback (
168- self , ** kwargs : Any
115+ self ,
116+ * ,
117+ invocation_context : InvocationContext ,
118+ user_message : types .Content ,
169119 ) -> Optional [types .Content ]:
170120 """Callback executed when a user message is received before an invocation starts.
171121
172122 This callback helps logging and modifying the user message before the
173123 runner starts the invocation.
174124
175125 Args:
176- callback_context : The context for the callback execution .
126+ invocation_context : The context for the entire invocation .
177127 user_message: The message content input by user.
178- invocation_context: DEPRECATED. Use callback_context instead. The context
179- for the entire invocation. This parameter is maintained for backward
180- compatibility and will be removed in a future version.
181128
182129 Returns:
183- The modified user message or None if no modification is needed.
130+ An optional `types.Content` to be returned to the ADK. Returning a
131+ value to replace the user message. Returning `None` to proceed
132+ normally.
184133 """
185- return None
134+ pass
186135
187- async def before_run_callback (self , ** kwargs : Any ) -> Optional [types .Content ]:
136+ async def before_run_callback (
137+ self , * , invocation_context : InvocationContext
138+ ) -> Optional [types .Content ]:
188139 """Callback executed before the ADK runner runs.
189140
190- This is the first lifecycle hook and is ideal for global setup, logging,
191- or checks that may stop the invocation from running .
141+ This is the first callback to be called in the lifecycle, ideal for global
142+ setup or initialization tasks .
192143
193144 Args:
194- callback_context: The context for the callback execution.
195- invocation_context: DEPRECATED. Use callback_context instead. The context
196- for the entire invocation. This parameter is maintained for backward
197- compatibility and will be removed in a future version.
145+ invocation_context: The context for the entire invocation, containing
146+ session information, the root agent, etc.
198147
199148 Returns:
200- Optional `types.Content` to halt execution and return the value to the
201- caller. Return `None` to proceed normally.
149+ An optional `Event` to be returned to the ADK. Returning a value to
150+ halt execution of the runner and ends the runner with that event. Return
151+ `None` to proceed normally.
202152 """
203- return None
153+ pass
204154
205- async def on_event_callback (self , ** kwargs : Any ) -> Optional [Event ]:
155+ async def on_event_callback (
156+ self , * , invocation_context : InvocationContext , event : Event
157+ ) -> Optional [Event ]:
206158 """Callback executed after an event is yielded from runner.
207159
160+ This is the ideal place to make modification to the event before the event
161+ is handled by the underlying agent app.
162+
208163 Args:
209- callback_context : The context for the callback execution .
164+ invocation_context : The context for the entire invocation .
210165 event: The event raised by the runner.
211- invocation_context: DEPRECATED. Use callback_context instead. The context
212- for the entire invocation. This parameter is maintained for backward
213- compatibility and will be removed in a future version.
214166
215167 Returns:
216- The modified event or None if no modification is needed.
168+ An optional value. A non-`None` return may be used by the framework to
169+ modify or replace the response. Returning `None` allows the original
170+ response to be used.
217171 """
218- return None
172+ pass
219173
220- async def after_run_callback (self , ** kwargs : Any ) -> None :
174+ async def after_run_callback (
175+ self , * , invocation_context : InvocationContext
176+ ) -> None :
221177 """Callback executed after an ADK runner run has completed.
222178
179+ This is the final callback in the ADK lifecycle, suitable for cleanup, final
180+ logging, or reporting tasks.
181+
223182 Args:
224- callback_context: The context for the callback execution.
225- invocation_context: DEPRECATED. Use callback_context instead. The context
226- for the entire invocation. This parameter is maintained for backward
227- compatibility and will be removed in a future version.
183+ invocation_context: The context for the entire invocation.
228184
229185 Returns:
230186 None
231187 """
232- return None
188+ pass
233189
234190 async def before_agent_callback (
235191 self , * , agent : BaseAgent , callback_context : CallbackContext
0 commit comments