[WIP] Refactor callback system to eliminate code duplication #3113
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.
[WIP] Refactor callback system to eliminate code duplication
Problem
The current callback system has significant code duplication:
canonical_*_callbacks
methods (42 lines of repeated code)Solution
Introduce a unified callback pipeline system:
Core Components
CallbackPipeline[TInput, TOutput]
- Type-safe generic pipeline executornormalize_callbacks()
- Replaces all 6 duplicate canonical methodsCallbackExecutor
- Integrates plugin + agent callbacksCode Example
Testing
Changes
New Files:
src/google/adk/agents/callback_pipeline.py
(+242 lines)tests/unittests/agents/test_callback_pipeline.py
(+391 lines)Stats:
Impact
Implementation Phases
This PR represents Phase 1-3 and 6 of a 10-phase refactoring plan:
Seeking feedback before proceeding with Phase 4-10.
Why This Approach?
Questions?
This is my first contribution to ADK. I'm happy to:
Looking forward to your review!