feat: Add progressive streaming for run_async via ProgressiveTool (partial progress + final result) #2698
+1,142
−26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Linked Issue
Closes: #2014
Summary
This PR introduces progressive streaming support for non-live runs (
run_async
).partial function_response
events.function_response
is injected back into the model.Rationale
Users need progress visibility for long-running tools during
run_async
, without switching to the live APIs.This feature mirrors live runner ergonomics while remaining opt-in and ensuring model reasoning is unchanged (only final outputs affect the model).
New API
google.adk.tools.progressive_function_tool.ProgressiveFunctionTool
(abstract base)google.adk.tools.progressive_tool.ProgressiveTool
(convenience wrapper)Supported patterns:
yield
→ partial; lastyield
→ finalprogress
orprogress_callback
: injected reporter emits partials; return value → finalChanges
src/google/adk/flows/llm_flows/base_llm_flow.py
_postprocess_handle_function_calls_async
updated to handle progressive tools (stream partials + final).src/google/adk/flows/llm_flows/functions.py
iter_progressive_function_calls_async(...)
to stream partials and yield a finalfunction_response
.src/google/adk/tools/progressive_function_tool.py
src/google/adk/tools/progressive_tool.py
_ignore_params
).src/google/adk/tools/__init__.py
ProgressiveTool
.Backward Compatibility
Testing Plan
Unit Tests (added)
Tools:
tests/unittests/tools/test_progressive_tool.py
progress
,progress_callback
)run_async
returns last yieldFlows:
tests/unittests/flows/llm_flows/test_progressive_flow.py
ProgressiveTool
ProgressiveFunctionTool
supportedFunctions:
tests/unittests/flows/llm_flows/test_functions_progressive_unit.py
Commands:
# Run only progressive tool/flow tests pytest -q tests/unittests/tools/test_progressive_tool.py \ tests/unittests/flows/llm_flows/test_progressive_flow.py \ tests/unittests/flows/llm_flows/test_functions_progressive_unit.py
Manual End-to-End (E2E)
Minimal script with
InMemoryRunner
+ProgressiveTool(export_report)
(async generator).Observed output (truncated):
Partial events:
Model Reply
The report for Germany has been exported and can be accessed at https://example.com/germany.pdf
Documentation
No user-facing docs changed in this PR.
A follow-up PR to
adk-docs
will add a short usage guide forProgressiveTool.