@@ -620,6 +620,34 @@ def on_tool_error(self, error, *args, run_id, **kwargs):
620620 self ._handle_error (run_id , error )
621621
622622
623+ def _get_request_data (obj , args , kwargs ):
624+ # type: (Any, Any, Any) -> tuple[Optional[str], Optional[List[Any]]]
625+ """
626+ Get the agent name and available tools for the agent.
627+ """
628+ agent = getattr (obj , "agent" , None )
629+ runnable = getattr (agent , "runnable" , None )
630+ runnable_config = getattr (runnable , "config" , {})
631+ tools = (
632+ getattr (obj , "tools" , None )
633+ or getattr (agent , "tools" , None )
634+ or runnable_config .get ("tools" )
635+ or runnable_config .get ("available_tools" )
636+ )
637+ tools = tools if tools and len (tools ) > 0 else None
638+
639+ try :
640+ agent_name = None
641+ if len (args ) > 1 :
642+ agent_name = args [1 ].get ("run_name" )
643+ if agent_name is None :
644+ agent_name = runnable_config .get ("run_name" )
645+ except Exception :
646+ pass
647+
648+ return (agent_name , tools )
649+
650+
623651def _wrap_configure (f ):
624652 # type: (Callable[..., Any]) -> Callable[..., Any]
625653
@@ -704,34 +732,6 @@ def new_configure(
704732 return new_configure
705733
706734
707- def _get_request_data (obj , args , kwargs ):
708- # type: (Any, Any, Any) -> tuple[Optional[str], Optional[List[Any]]]
709- """
710- Get the agent name and available tools for the agent.
711- """
712- agent = getattr (obj , "agent" , None )
713- runnable = getattr (agent , "runnable" , None )
714- runnable_config = getattr (runnable , "config" , {})
715- tools = (
716- getattr (obj , "tools" , None )
717- or getattr (agent , "tools" , None )
718- or runnable_config .get ("tools" )
719- or runnable_config .get ("available_tools" )
720- )
721- tools = tools if tools and len (tools ) > 0 else None
722-
723- try :
724- agent_name = None
725- if len (args ) > 1 :
726- agent_name = args [1 ].get ("run_name" )
727- if agent_name is None :
728- agent_name = runnable_config .get ("run_name" )
729- except Exception :
730- pass
731-
732- return (agent_name , tools )
733-
734-
735735def _wrap_agent_executor_invoke (f ):
736736 # type: (Callable[..., Any]) -> Callable[..., Any]
737737
0 commit comments