4545from  ..utils .feature_decorator  import  experimental 
4646from  .base_agent_config  import  BaseAgentConfig 
4747from  .callback_context  import  CallbackContext 
48+ from  .callback_pipeline  import  normalize_callbacks 
4849
4950if  TYPE_CHECKING :
5051  from  .invocation_context  import  InvocationContext 
@@ -404,30 +405,6 @@ def _create_invocation_context(
404405    invocation_context  =  parent_context .model_copy (update = {'agent' : self })
405406    return  invocation_context 
406407
407-   @property  
408-   def  canonical_before_agent_callbacks (self ) ->  list [_SingleAgentCallback ]:
409-     """The resolved self.before_agent_callback field as a list of _SingleAgentCallback. 
410- 
411-     This method is only for use by Agent Development Kit. 
412-     """ 
413-     if  not  self .before_agent_callback :
414-       return  []
415-     if  isinstance (self .before_agent_callback , list ):
416-       return  self .before_agent_callback 
417-     return  [self .before_agent_callback ]
418- 
419-   @property  
420-   def  canonical_after_agent_callbacks (self ) ->  list [_SingleAgentCallback ]:
421-     """The resolved self.after_agent_callback field as a list of _SingleAgentCallback. 
422- 
423-     This method is only for use by Agent Development Kit. 
424-     """ 
425-     if  not  self .after_agent_callback :
426-       return  []
427-     if  isinstance (self .after_agent_callback , list ):
428-       return  self .after_agent_callback 
429-     return  [self .after_agent_callback ]
430- 
431408  async  def  _handle_before_agent_callback (
432409      self , ctx : InvocationContext 
433410  ) ->  Optional [Event ]:
@@ -450,11 +427,9 @@ async def _handle_before_agent_callback(
450427
451428    # If no overrides are provided from the plugins, further run the canonical 
452429    # callbacks. 
453-     if  (
454-         not  before_agent_callback_content 
455-         and  self .canonical_before_agent_callbacks 
456-     ):
457-       for  callback  in  self .canonical_before_agent_callbacks :
430+     callbacks  =  normalize_callbacks (self .before_agent_callback )
431+     if  not  before_agent_callback_content  and  callbacks :
432+       for  callback  in  callbacks :
458433        before_agent_callback_content  =  callback (
459434            callback_context = callback_context 
460435        )
@@ -510,11 +485,9 @@ async def _handle_after_agent_callback(
510485
511486    # If no overrides are provided from the plugins, further run the canonical 
512487    # callbacks. 
513-     if  (
514-         not  after_agent_callback_content 
515-         and  self .canonical_after_agent_callbacks 
516-     ):
517-       for  callback  in  self .canonical_after_agent_callbacks :
488+     callbacks  =  normalize_callbacks (self .after_agent_callback )
489+     if  not  after_agent_callback_content  and  callbacks :
490+       for  callback  in  callbacks :
518491        after_agent_callback_content  =  callback (
519492            callback_context = callback_context 
520493        )
0 commit comments