fix(workflow): scope dynamic node cache rehydration to current invocation#1010
Merged
Conversation
…tion rehydrateCache scanned the entire session history and cached child outputs keyed by childPath, without filtering by invocation_id. Because auto-counter run-ids reset to 1 on every fresh activation, a later user turn reuses the same childPath (e.g. "wf/child@1") as a prior turn, so the stale output was served from cache and the child never re-ran. This caused the dynamic workflow example to return empty output on the second and subsequent turns. Filter rehydration to events from the current invocation, mirroring adk-python (_reconstruct_node_states / _scan_parent_child_sequence gate on event.invocation_id). Within-invocation resume/dedup is preserved.
hanorik
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
A dynamic workflow (e.g.
examples/workflow/dynamic/basic) returns emptyoutput on the second and every subsequent turn of the same session. The first
turn works; later turns print nothing.
Root cause:
dynamicSubScheduler.rehydrateCachescans the entire sessionhistory and caches child outputs keyed by
childPath, without filtering byinvocation. Auto-counter run-ids reset to
1on every fresh activation, so alater user turn reuses the same
childPath(e.g.wf/child@1) as a priorturn. The stale output is served from cache, the child never re-runs, and the
parent's terminal event carries an
Outputbut noContent— so the console(which prints content text) shows nothing.
Solution
Filter rehydration to events from the current invocation. Stale events from
earlier turns are skipped, so a fresh turn re-runs its children; events from the
current invocation still hit, preserving within-invocation resume/dedup (the
HITL replay path).
This mirrors adk-python, which gates rehydration on
event.invocation_id(
_reconstruct_node_states/_scan_parent_child_sequence).