Skip to content

Commit 89e2dbc

Browse files
committed
refactor: return copy of callbacks list to improve encapsulation
- Changed callbacks property to return a copy instead of direct reference - Prevents external modification of internal pipeline state - Addresses bot review feedback for better defensive programming
1 parent 0f38f17 commit 89e2dbc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/google/adk/agents/callback_pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ def has_callbacks(self) -> bool:
139139

140140
@property
141141
def callbacks(self) -> list[Callable]:
142-
"""Returns the list of callbacks in the pipeline.
142+
"""Returns a copy of the list of callbacks in the pipeline.
143143
144144
Returns:
145145
List of callback functions.
146146
"""
147-
return self._callbacks
147+
return self._callbacks.copy()
148148

149149

150150
def normalize_callbacks(

0 commit comments

Comments
 (0)