Skip to content

Commit 9b76072

Browse files
committed
refactor: address code review feedback
- Remove unused TypeVars (TInput, TCallback) - Simplify CallbackExecutor by reusing CallbackPipeline - Reduces code duplication and improves maintainability Addresses feedback from gemini-code-assist bot review
1 parent aa46ff3 commit 9b76072

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/google/adk/agents/callback_pipeline.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@
4242
from typing import Union
4343

4444

45-
TInput = TypeVar('TInput')
4645
TOutput = TypeVar('TOutput')
47-
TCallback = TypeVar('TCallback', bound=Callable)
4846

4947

50-
class CallbackPipeline(Generic[TInput, TOutput]):
48+
class CallbackPipeline(Generic[TOutput]):
5149
"""Unified callback execution pipeline.
5250
5351
This class provides a consistent way to execute callbacks with the following
@@ -241,17 +239,10 @@ async def execute_with_plugins(
241239
... )
242240
"""
243241
# Step 1: Execute plugin callback (priority)
244-
result = plugin_callback(*args, **kwargs)
245-
if inspect.isawaitable(result):
246-
result = await result
247-
242+
result = await CallbackPipeline([plugin_callback]).execute(*args, **kwargs)
248243
if result is not None:
249244
return result
250245

251246
# Step 2: Execute agent callbacks if plugin returned None
252-
if agent_callbacks:
253-
pipeline = CallbackPipeline(callbacks=agent_callbacks)
254-
result = await pipeline.execute(*args, **kwargs)
255-
256-
return result
247+
return await CallbackPipeline(agent_callbacks).execute(*args, **kwargs)
257248

0 commit comments

Comments
 (0)