Skip to content

fix(runners): honor yield_user_message for composite-agent roots - #8408

Open
sumedh-aerram wants to merge 4 commits into
google:mainfrom
sumedh-aerram:fix/runner-yield-user-message
Open

sumedh-aerram wants to merge 4 commits into
google:mainfrom
sumedh-aerram:fix/runner-yield-user-message

Conversation

@sumedh-aerram

@sumedh-aerram sumedh-aerram commented Nov 27, 2026 •

Copy link
Copy Markdown

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:

  • before_run short-circuit: the stored user event is yielded, followed by the callback's early-exit event.
  • State-delta-only resume: the content-less user event that carries the delta is yielded.
  • Resume with no new message or delta: nothing new is stored and nothing is yielded.
  • Resume of an already-finished invocation: no agent runs. Any user event stored during setup (such as a state-delta event) is still yielded, then the run returns.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • Relevant new and existing runner unit tests pass locally.

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:

  • 114 cases cover SequentialAgent, ParallelAgent, LoopAgent, direct LlmAgent and BaseNode roots. They run with the flag true, false and default, and cover resumable and non-resumable new turns, modified messages, before_run short-circuits, resume with no new message (seeded paused state), state-delta-only resume, resume with a function response, and duplicate-message suppression. A separate verification also drove a real pause through a long-running tool and resumed it (function response and state-delta only) for all three composite roots; the yielded user event id matched the stored one. They assert that the yielded event is the stored event (same ID), that the user event comes first, and that only agent or callback events follow it.
  • 12 cases resume an already-finished invocation for each composite root, with no new input and with a state delta only. They assert that the model is not called again, and that the yielded events equal the stored events (or are empty when the flag is false).

Without the fix (upstream runners.py, same tests): 21 failed, 105 passed. All 21 failures are yield_user_message=True composite-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.py passes. Mypy reports no issues on runners.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

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective.
  • Relevant new and existing unit tests pass locally with my changes.
  • I have manually tested the offline reproduction end-to-end.

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.

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
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.

Runner.run_async ignores yield_user_message=True for composite-agent roots

1 participant