Commit 5898f37
fix: prevent VertexAiRagRetrieval from blocking the event loop
VertexAiRagRetrieval.run_async() called rag.retrieval_query() directly. That
call issues a synchronous, blocking gRPC request which freezes the asyncio
event loop for ~1-2s on every invocation, even though run_async is an async
method. This is especially harmful for real-time/streaming use cases
(StreamingMode.BIDI with gemini-live models), causing audio/video desync and
dropped frames.
Defer the blocking call to a worker thread via asyncio.to_thread, matching the
established pattern already used across ADK (e.g. the GCS/file artifact
services and the Spanner/BigQuery tools).
Closes #5033
Co-authored-by: Haran Rajkumar <haranrk@google.com>
PiperOrigin-RevId: 9340145251 parent 7443bfa commit 5898f37
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | | - | |
| 98 | + | |
| 99 | + | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| |||
0 commit comments