-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
google-adk version 1.22.1 (Python)
Description
Plugin callbacks before_model_callback and after_model_callback defined in BasePlugin are correctly invoked during
regular async sessions (run_async), but are completely bypassed during live streaming sessions (run_live). This
causes plugins that depend on these callbacks for analytics, logging, request/response modification, or other
model-level interception to silently fail when used with live streaming.
Steps to Reproduce
- Create a plugin implementing before_model_callback and/or after_model_callback
- Register and run with run_async → callbacks fire ✅
- Run with run_live → callbacks never fire ❌
Code References
Path: run_async → _call_llm_async()
Behavior: ✅ Calls _handle_before_model_callback() and _handle_after_model_callback()
────────────────────────────────────────
Path: run_live → _receive_from_model() → _postprocess_live()
Behavior: ❌ Bypasses callback handlers entirely
Files:
- src/google/adk/flows/llm_flows/base_llm_flow.py (lines 86-186 for run_live, lines 733-822 for _call_llm_async)
- src/google/adk/agents/llm_agent.py
Callback Comparison
┌───────────────────────┬───────────┬───────────────┐
│ Callback │ run_async │ run_live │
├───────────────────────┼───────────┼───────────────┤
│ before_run_callback │ ✅ Works │ ✅ Works │
├───────────────────────┼───────────┼───────────────┤
│ after_run_callback │ ✅ Works │ ✅ Works │
├───────────────────────┼───────────┼───────────────┤
│ on_event_callback │ ✅ Works │ ✅ Works │
├───────────────────────┼───────────┼───────────────┤
│ before_model_callback │ ✅ Works │ ❌ Not called │
├───────────────────────┼───────────┼───────────────┤
│ after_model_callback │ ✅ Works │ ❌ Not called │
└───────────────────────┴───────────┴───────────────┘
Impact
- Analytics/telemetry plugins miss live session data
- Request/response modification plugins silently fail
- No warning or error - plugins just don't work
Suggested Fix
Add calls to _handle_before_model_callback() and _handle_after_model_callback() in the run_live() flow, similar to
_call_llm_async().