-
Notifications
You must be signed in to change notification settings - Fork 792
Description
Summary
The callback documentation shows examples with specific parameter names like callback_context and llm_request, but doesn't explicitly state that these exact names are required. Users may assume they can use any parameter name (e.g., ctx instead of callback_context), leading to confusing runtime errors.
Problem
When defining a callback with a different parameter name:
async def my_callback(ctx: CallbackContext) -> Optional[types.Content]:
# ...The callback fails at runtime with:
TypeError: my_callback() got an unexpected keyword argument 'callback_context'
This happens because ADK invokes callbacks using keyword arguments:
callback(callback_context=callback_context, llm_request=llm_request)Expected Behavior
The documentation should explicitly state that callback parameter names must match the expected names exactly, such as:
callback_context(notctx,context, etc.)llm_request/llm_responsetool,args,tool_context,tool_response
Suggested Fix
Add a note to the Callbacks documentation or Types of Callbacks page, such as:
Important: Callback parameter names must match exactly as shown in the examples. ADK invokes callbacks using keyword arguments, so using different parameter names (e.g.,
ctxinstead ofcallback_context) will result in aTypeError.