feat(plugin): implement on_pipeline_error_callback lifecycle hook#5988
feat(plugin): implement on_pipeline_error_callback lifecycle hook#5988mramansayyad wants to merge 3 commits into
Conversation
|
Response from ADK Triaging Agent Hello @mramansayyad, thank you for submitting this pull request! To help us review your contribution more efficiently, please ensure that it aligns with our contribution guidelines. Currently, the following items are missing from your PR description:
Providing this context will save time for the reviewers. Thank you for your cooperation! |
|
/adk-pr-analyze |
🔍 ADK Pull Request Analysis: PR #5988Title: feat(plugin): implement on_pipeline_error_callback lifecycle hook Executive Summary
Detailed Findings & Analysis1. Objectives & Impact ("What does it do?")
2. Justification & Value ("Is it a valid and useful change?")
3. Principle & Style Alignment Checklist ("Does it follow rules?")
|
4b27902 to
3453827
Compare
🔍 ADK Pull Request Analysis: PR #5988Title: feat(plugin): implement on_pipeline_error_callback lifecycle hook Executive Summary
Detailed Findings & Analysis1. Objectives & Impact ("What does it do?")
2. Justification & Value ("Is it a valid and useful change?")
3. Principle & Style Alignment Checklist ("Does it follow rules?")
Currently, the active local branch has been safely returned to |
|
Hello, I have updated the PR description to include the associated issue context, testing plan, and local test logs. Please let me know if any other changes are needed! Thank you. |
|
/adk-pr-analyze |
|
/adk-pr-analyze |
|
Hi maintainers, could you please assign this PR to me? Thank you! |
|
Hi @rohityan, I have resolved the style nit regarding eager f-string formatting inside the exception logging blocks in All 14 unit tests (including the new tests verifying callback registration, sequential mutative exception chaining, and plugin fault wrap isolation) pass cleanly. Local Test Execution Results:$ pytest tests/unittests/plugins/test_plugin_manager.py -v
============================= test session starts =============================
platform win32 -- Python 3.10.11, pytest-9.0.3, pluggy-1.6.0
rootdir: D:\Projects\GSSOC\adk-python
configfile: pyproject.toml
plugins: anyio-4.12.1, asyncio-1.4.0, mock-3.15.1
asyncio: mode=auto, debug=False, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function
collecting ... collected 14 items
tests/unittests/plugins/test_plugin_manager.py::test_register_and_get_plugin PASSED [ 7%]
tests/unittests/plugins/test_plugin_manager.py::test_register_duplicate_plugin_name_raises_value_error PASSED [ 14%]
tests/unittests/plugins/test_early_exit_stops_subsequent_plugins PASSED [ 21%]
tests/unittests/plugins/test_normal_flow_all_plugins_are_called PASSED [ 28%]
tests/unittests/plugins/test_plugin_exception_is_wrapped_in_runtime_error PASSED [ 35%]
tests/unittests/plugins/test_all_callbacks_are_supported PASSED [ 42%]
tests/unittests/plugins/test_close_calls_plugin_close PASSED [ 50%]
tests/unittests/plugins/test_close_raises_runtime_error_on_plugin_exception PASSED [ 57%]
tests/unittests/plugins/test_close_with_timeout PASSED [ 64%]
tests/unittests/plugins/test_close_is_noop_after_set_skip_closing_plugins PASSED [ 71%]
tests/unittests/plugins/test_set_skip_closing_plugins_bypasses_close_timeout PASSED [ 78%]
tests/unittests/plugins/test_set_skip_closing_plugins_false_reverts_to_closing PASSED [ 85%]
tests/unittests/plugins/test_pipeline_error_callback_chaining PASSED [ 92%]
tests/unittests/plugins/test_pipeline_error_callback_exception_wrap PASSED [100%]
======================= 14 passed, 4 warnings in 3.53s ========================Please let me know if this looks good to merge! |
Description
This PR implements the
on_pipeline_error_callbacklifecycle hook onBasePluginandPluginManager, bringingadk-pythonto feature parity with the corresponding capabilities inadk-go.Associated Issue
This PR introduces the feature/parity capability directly without a separate GitHub issue, following the issue template structure below:
adk-pythondoes not expose a lifecycle hook to capture pipeline-level/runner-level errors across plugins. In contrast,adk-goprovideson_pipeline_error_callback, which allows plugins to clean up resources, rollback operations, or report/format errors before they propagate out.on_pipeline_error_callback(self, error: Exception, **kwargs) -> ExceptiontoBasePlugin.run_on_pipeline_error_callback(self, invocation_context: InvocationContext, error: Exception) -> ExceptioninPluginManagerto chain the error callbacks across registered plugins.runners.py) by wrapping the primary yield-loops intry...exceptblocks that invoke the pipeline error hook before re-raising or modifying the exception.Logs or Screenshots
Executing the unit tests verifies the correctness of the lifecycle hooks:
Testing Plan
A dedicated set of unit tests was added to
tests/unittests/plugins/test_plugin_manager.py:test_all_callbacks_are_supported: Verifieson_pipeline_error_callbackis registered and callable onPluginManager.test_pipeline_error_callback_chaining: Verifies that the exception is passed through the registered plugins sequentially and can be modified/returned.test_pipeline_error_callback_exception_wrap: Verifies that plugin callback failures are cleanly wrapped in aRuntimeErrorand propagated.How to Run the Tests
To verify locally, run the following command in the
adk-pythondirectory:Type of change
Checklist
CHANGELOG.md