Skip to content

fix(runners): run on_run_error_callback for invocation setup failures - #8406

Open
sumedh-aerram wants to merge 1 commit into
google:mainfrom
sumedh-aerram:fix/runner-setup-error-callback
Open

sumedh-aerram wants to merge 1 commit into
google:mainfrom
sumedh-aerram:fix/runner-setup-error-callback

Conversation

@sumedh-aerram

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 #8405

Problem:
Composite roots handle incoming messages before entering the invocation lifecycle. A user-message callback or user-event append failure therefore escapes without notifying on_run_error_callback. Resumed message and state-only appends have the same gap.

Solution:
Catch ordinary message-setup exceptions in the new and resumed invocation helpers, notify through the existing best-effort helper, and re-raise the same propagated exception. Keep execution-error notification and success-only after_run_callback behavior unchanged.

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: 368 passed, 1 skipped, 3 xfailed.

29 regression/control cases across SequentialAgent, ParallelAgent, LoopAgent, direct LlmAgent and BaseNode roots: user-message callback failures, session append failures, resumed function-response setup, state-only resume appends, and execution failures. Assert exactly one run-error callback with the propagated exception and no after-run callback.

Unpatched upstream with the final focused tests: 15 failed, 14 passed. Patched: 29 focused cases pass. Full runner-suite counts above include those cases. The skip and expected failures are existing tests.

pre-commit run --files src/google/adk/runners.py tests/unittests/test_runners.py passes. Mypy reports the same 521 existing test diagnostics as upstream, with zero new errors; the changed runner source has no errors.

Manual End-to-End (E2E) Tests:

Run the offline code in the linked issue against a source checkout. After the fix: LlmAgent: exception=RuntimeError error_hooks=1 notified_original=True and SequentialAgent: exception=RuntimeError error_hooks=1 notified_original=True.

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.

Notify run-error plugins when composite-root message setup or resumed state appends fail, preserving the original propagated exception and success-only after-run callbacks.

Fixes google#8405
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.

Composite-agent runner setup failures bypass on_run_error_callback

1 participant