🔴 Required Information
Describe the Bug:
Follow-up to #7160, split out as requested there. forecast, analyze_contribution and detect_anomalies in the BigQuery toolset have the same problem that #7160 reported for execute_sql: they are plain defs that call the blocking _execute_sql helper directly (src/google/adk/integrations/bigquery/query_tool.py, L934, L1143 and L1375). ADK awaits a sync tool inline on the running loop, so nothing else in the process runs until the queries come back.
analyze_contribution and detect_anomalies call _execute_sql twice in a row (CREATE TEMP MODEL, then ML.GET_INSIGHTS / ML.DETECT_ANOMALIES), so the loop stays blocked for both queries, including model training.
#7161 fixes execute_sql only and leaves these three untouched on purpose.
Steps to Reproduce:
The repro script in #7160 should apply here too, with the execute_sql call replaced by one of these three tools. analyze_contribution and detect_anomalies also need a write_mode other than BLOCKED.
Expected Behavior:
Other tasks on the event loop keep running while these tools wait for BigQuery.
Observed Behavior:
From the code, the same as #7160: the event loop is blocked for the whole tool call, which for analyze_contribution and detect_anomalies covers both queries.
Environment Details:
- ADK Library Version (pip show google-adk):
main at 7ae1c9b
- Desktop OS: N/A
- Python Version (python -V): N/A
Model Information:
- Are you using LiteLLM: No
- Which model is being used: N/A, no model involved
🟡 Optional Information
Regression:
No, they have always been sync.
Additional Context:
The fix would follow #7161: make the three tools coroutines and run the blocking work in a thread with asyncio.to_thread. It makes sense to pick this up once #7161 is merged and its approach is settled, so the same pattern applies here.
For analyze_contribution and detect_anomalies, one open point is whether both queries go into a single to_thread call or each _execute_sql call gets its own.
🔴 Required Information
Describe the Bug:
Follow-up to #7160, split out as requested there.
forecast,analyze_contributionanddetect_anomaliesin the BigQuery toolset have the same problem that #7160 reported forexecute_sql: they are plaindefs that call the blocking_execute_sqlhelper directly (src/google/adk/integrations/bigquery/query_tool.py, L934, L1143 and L1375). ADK awaits a sync tool inline on the running loop, so nothing else in the process runs until the queries come back.analyze_contributionanddetect_anomaliescall_execute_sqltwice in a row (CREATE TEMP MODEL, thenML.GET_INSIGHTS/ML.DETECT_ANOMALIES), so the loop stays blocked for both queries, including model training.#7161 fixes
execute_sqlonly and leaves these three untouched on purpose.Steps to Reproduce:
The repro script in #7160 should apply here too, with the
execute_sqlcall replaced by one of these three tools.analyze_contributionanddetect_anomaliesalso need awrite_modeother thanBLOCKED.Expected Behavior:
Other tasks on the event loop keep running while these tools wait for BigQuery.
Observed Behavior:
From the code, the same as #7160: the event loop is blocked for the whole tool call, which for
analyze_contributionanddetect_anomaliescovers both queries.Environment Details:
mainat 7ae1c9bModel Information:
🟡 Optional Information
Regression:
No, they have always been sync.
Additional Context:
The fix would follow #7161: make the three tools coroutines and run the blocking work in a thread with
asyncio.to_thread. It makes sense to pick this up once #7161 is merged and its approach is settled, so the same pattern applies here.For
analyze_contributionanddetect_anomalies, one open point is whether both queries go into a singleto_threadcall or each_execute_sqlcall gets its own.