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 (not ctx, context, etc.)
llm_request / llm_response
tool, 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., ctx instead of callback_context) will result in a TypeError.
Affected Pages
Summary
The callback documentation shows examples with specific parameter names like
callback_contextandllm_request, but doesn't explicitly state that these exact names are required. Users may assume they can use any parameter name (e.g.,ctxinstead ofcallback_context), leading to confusing runtime errors.Problem
When defining a callback with a different parameter name:
The callback fails at runtime with:
This happens because ADK invokes callbacks using keyword arguments:
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_responseSuggested Fix
Add a note to the Callbacks documentation or Types of Callbacks page, such as:
Affected Pages