@@ -315,11 +315,11 @@ def invocation_parameters(run: Run) -> Iterator[tuple[str, str]]:
315315 return
316316 if not (extra := run .extra ):
317317 return
318- if not hasattr (extra , "get" ):
319- raise TypeError ( f"expected Mapping, found { type ( extra ) } " )
318+ if not isinstance (extra , Mapping ):
319+ return
320320 if invocation_parameters := extra .get ("invocation_params" ):
321321 if not isinstance (invocation_parameters , Mapping ):
322- raise TypeError ( f"expected Mapping, found { type ( invocation_parameters ) } " )
322+ return
323323 tools = invocation_parameters .get ("tools" , [])
324324 for idx , tool in enumerate (tools ):
325325 yield f"{ GEN_AI_TOOL_ARGS_KEY } .{ idx } " , safe_json_dumps (tool )
@@ -352,8 +352,8 @@ def model_name(
352352 return
353353 if not extra :
354354 return
355- if not hasattr (extra , "get" ):
356- raise TypeError ( f"expected Mapping, found { type ( extra ) } " )
355+ if not isinstance (extra , Mapping ):
356+ return
357357 if (
358358 (metadata := extra .get ("metadata" ))
359359 and hasattr (metadata , "get" )
@@ -458,8 +458,8 @@ def function_calls(outputs: Mapping[str, Any] | None) -> Iterator[tuple[str, str
458458 """
459459 if not outputs :
460460 return
461- if not hasattr (outputs , "get" ):
462- raise TypeError ( f"expected Mapping, found { type ( outputs ) } " )
461+ if not isinstance (outputs , Mapping ):
462+ return
463463
464464 try :
465465 # Typical OpenAI LangChain shape:
@@ -514,8 +514,8 @@ def tools(run: Run) -> Iterator[tuple[str, str]]:
514514 return
515515 if not (serialized := run .serialized ):
516516 return
517- if not hasattr (serialized , "get" ):
518- raise TypeError ( f"expected Mapping, found { type ( serialized ) } " )
517+ if not isinstance (serialized , Mapping ):
518+ return
519519 yield GEN_AI_TOOL_TYPE_KEY , "extension"
520520 if name := serialized .get ("name" ):
521521 yield GEN_AI_TOOL_NAME_KEY , name
@@ -627,8 +627,8 @@ def invoke_agent_input_message(
627627 if not inputs :
628628 return
629629
630- if not hasattr (inputs , "get" ):
631- raise TypeError ( f"expected Mapping, found { type ( inputs ) } " )
630+ if not isinstance (inputs , Mapping ):
631+ return
632632
633633 messages = inputs .get ("messages" )
634634 if not messages :
@@ -669,8 +669,8 @@ def invoke_agent_output_message(
669669 if not outputs :
670670 return
671671
672- if not hasattr (outputs , "get" ):
673- raise TypeError ( f"expected Mapping, found { type ( outputs ) } " )
672+ if not isinstance (outputs , Mapping ):
673+ return
674674
675675 messages = outputs .get ("messages" )
676676 if not messages :
0 commit comments