Skip to content

Fix/5602 longrunningfunctiontool resume#5832

Open
ilyesJammouci wants to merge 3 commits into
google:mainfrom
ilyesJammouci:fix/5602-longrunningfunctiontool-resume
Open

Fix/5602 longrunningfunctiontool resume#5832
ilyesJammouci wants to merge 3 commits into
google:mainfrom
ilyesJammouci:fix/5602-longrunningfunctiontool-resume

Conversation

@ilyesJammouci
Copy link
Copy Markdown

Fixes #5602

Summary

Compaction incorrectly folded unresolved long-running function call events when an intermediate/pending function_response (e.g. with status: "pending") shared the same id as the function_call.

This caused resume responses arriving later to fail during contents assembly with:

No function call event found for function responses ids: {...}

As a result, resumability for long-running tools was broken.


Changes

event_actions.py

  • Added is_intermediate_long_running_response to EventActions
  • Used to mark pending LRF function_response events

compaction.py

  • Updated _event_function_response_ids
  • Intermediate LRF responses are now ignored when computing resolved response ids
  • Prevents compaction from treating pending responses as final responses

functions.py

  • When emitting a pending live long-running tool response:
tool_context.actions.is_intermediate_long_running_response = True
  • Ensures the produced event is properly flagged

Before

Compaction scanned all function_response ids unconditionally.

An intermediate/pending function_response could hide the matching function_call id from pending-call detection, allowing the compactor to prematurely fold away the function_call event.


After

Intermediate/pending LRF function_response events are explicitly marked and ignored during compaction when computing resolved response ids.

This preserves unresolved function_call events until the real resume response arrives, maintaining resumability semantics.


Motivation

Long-running tools emit intermediate/pending updates (e.g. status: pending) that should not be treated as final responses during compaction.

Previously, folding the matching function_call event caused later resume responses to become orphaned, leading to failures during contents assembly.

This fix introduces an explicit marker and minimally adjusts compaction response-id extraction logic to avoid the issue.


Test Plan

Unit Test

Added regression test:

tests/unittests/apps/test_compaction.py::test_sliding_window_preserves_long_running_call_until_resume

The test:

  • Reproduces the compaction + resume failure scenario
  • Verifies the long-running function_call is preserved until the actual resume response arrives

Run:

pytest tests/unittests/apps/test_compaction.py::test_sliding_window_preserves_long_running_call_until_resume

Expected:

  • Test passes
  • No contents assembly exception occurs when the resume response arrives

Manual Verification

  • Run existing compaction and resumability flows
  • Confirm:
    • Non-LRF behavior remains unchanged
    • LRF resume flow now succeeds correctly

@adk-bot adk-bot added the services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc label May 24, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented May 24, 2026

Response from ADK Triaging Agent

Hello @ilyesJammouci, thank you for creating this high-quality pull request!

We appreciate the detailed summary, the test plan, and the regression unit test you provided. To ensure this PR fully aligns with our contribution guidelines, could you please provide:

  1. A summary or output snippet of the passed pytest results showing the new unit test passing.
  2. Logs or screenshots from your manual verification (e.g., console output from the run) after the fix was applied.

This extra verification info helps reviewers better understand the fix and speeds up the review process. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compaction breaks LongRunningFunctionTool resume

2 participants