Skip to content

fix(flows): resume long-running tools after matching responses#5072

Open
zeel2104 wants to merge 1 commit intogoogle:mainfrom
zeel2104:fix-5064-long-running-resume
Open

fix(flows): resume long-running tools after matching responses#5072
zeel2104 wants to merge 1 commit intogoogle:mainfrom
zeel2104:fix-5064-long-running-resume

Conversation

@zeel2104
Copy link
Copy Markdown

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

Problem:
LongRunningFunctionTool resume could fail in resumable flows when streaming was enabled. There were two compounding issues:

  1. Resume logic could still treat an invocation as paused even after a matching functionResponse had already resolved the long-running tool call.
  2. Streaming partial and final model events could end up with different ADK-generated function call IDs, causing resume-time lookup of the original function call event to fail.

Solution:
This change fixes both sides of the resume path:

  1. It adds unresolved-pause detection that checks long-running tool calls against all matching functionResponse IDs in the current invocation branch before deciding to stop execution.
  2. It preserves previously assigned function call IDs across streaming partial and final model response events so the client-visible ID remains stable and matches the event persisted in session history.

Testing Plan

I verified the change with targeted unit tests covering both parts of the fix:

resumable invocation logic now continues when a long-running tool call has a matching functionResponse
streaming finalization preserves function call IDs across partial and final events

Commands run

python -m pytest tests\unittests\agents\test_invocation_context.py tests\unittests\flows\llm_flows\test_base_llm_flow.py -q --basetemp=.pytest_tmp
python -m pytest tests\unittests\agents\test_invocation_context.py -q -k "has_unresolved_long_running_tool_calls" --basetemp=.pytest_tmp
python -m pytest tests\unittests\flows\llm_flows\test_base_llm_flow.py -q -k "preserves_function_call_ids" --basetemp=.pytest_tmp

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Passed locally:

python -m pytest tests\unittests\agents\test_invocation_context.py tests\unittests\flows\llm_flows\test_base_llm_flow.py -q --basetemp=.pytest_tmp

**Manual End-to-End (E2E) Tests:**

Manual E2E tests were not run. I validated the behavior through targeted unit tests that cover the unresolved pause check and streaming function call ID stability, but I did not run a full end-to-end resumable streaming flow through the CLI/web/API with a live client resume sequence.


### Checklist

- [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document.
- [x] I have performed a self-review of my own code.
- [x] I have commented my code, particularly in hard-to-understand areas.
- [x] I have added tests that prove my fix is effective or that my feature works.
- [x] New and existing unit tests pass locally with my changes.
- [x] I have manually tested my changes end-to-end.
- [x] Any dependent changes have been merged and published in downstream modules.

### Additional context

This fix is intentionally narrow:

resume behavior now only remains paused when a long-running tool call is still unresolved
streaming function call IDs are preserved across partial and final events so resume routing remains stable
The local test setup on Windows required installing the package with uv pip install -e . plus pytest dependencies directly, because the full test extra currently pulls a dependency chain that includes lancedb, which does not have a compatible wheel in this environment.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 30, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@rohityan rohityan self-assigned this Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LongRunningFunctionTool resume fails: unresolved pause check + streaming ID mismatch

2 participants