Repository navigation
fix(runners): honor yield_user_message for composite-agent roots - #8408
Open
sumedh-aerram wants to merge 4 commits into
Open
sumedh-aerram wants to merge 4 commits into
sumedh-aerram wants to merge 4 commits into
Conversation
Yield newly persisted composite-root user events before execution when requested, preserving event identity and existing default and resume behavior. Fixes google#8407
…ield_user_message Resuming an invocation that already finished runs no agent, but any user event stored during setup (a state-delta-only event) is still yielded when yield_user_message is True. Also assert the yielded user event is followed only by agent or before_run events.
…er-message # Conflicts: # src/google/adk/runners.py
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Fixes #8407
Problem:
Composite roots persist the incoming user event but omit it from the public stream even when
yield_user_message=True. Direct LlmAgent and node roots already honor the flag.Solution:
Record the session-event count before new or resumed composite-root setup, then yield the user events that setup stored right before
_exec_with_plugin. The yielded objects are the stored events, so ID, invocation ID, transformed content and state delta match the session. This applies to every root that goes through_run_with_trace(SequentialAgent, ParallelAgent, LoopAgent). LlmAgent and node roots are unchanged. The default (False) is unchanged.Behavior with
yield_user_message=True, matching the node runtime path:Testing Plan
Unit Tests:
pytest tests/unittests/test_runners.py tests/unittests/runners -q: 465 passed, 1 skipped, 3 xfailed.pytest tests/unittests/agents tests/unittests/flows tests/unittests/workflow -q -n 8: 3732 passed, 3 xfailed.126 focused cases:
Without the fix (upstream
runners.py, same tests): 21 failed, 105 passed. All 21 failures areyield_user_message=Truecomposite-root cases where setup stored an event. With the fix: 126 passed.pre-commit run --files src/google/adk/runners.py tests/unittests/test_runners.pypasses. Mypy reports no issues onrunners.py. On the test file it reports the same 521 existing diagnostics as before the change, so there are no new errors.Manual End-to-End (E2E) Tests:
Run the offline code in the linked issue against a source checkout. After the fix: both roots print
yielded=['user', 'child'] stored=['user', 'child'].Checklist
Additional context
The node and direct LlmAgent runtime paths retain their existing behavior. No new API, configuration, sample, or documentation contract is introduced; this restores the documented runner behavior.