@@ -624,35 +624,42 @@ def agent_model(
624624 "async_client" ,
625625 "azure_deployment_name" ,
626626 }
627- init_params = {
628- k : v
629- for k , v in extra_params .items ()
630- if k in init_param_keys and v is not None and (not isinstance (v , str ) or v .strip () != "" )
631- }
627+
628+ init_params = {}
632629 model_config : dict [str , Any ] = {}
630+
633631 if options .is_cloud ():
634632 model_config ["user" ] = str (options .project_id )
635- model_config .update (
636- {
637- k : v
638- for k , v in extra_params .items ()
639- if k not in init_param_keys and k not in ["model_platform" , "model_type" , "api_key" , "url" ]
640- }
641- )
633+
634+ excluded_keys = {"model_platform" , "model_type" , "api_key" , "url" }
635+
636+ # Distribute extra_params between init_params and model_config
637+ for k , v in extra_params .items ():
638+ if k in excluded_keys :
639+ continue
640+ # Skip empty values
641+ if v is None or (isinstance (v , str ) and not v .strip ()):
642+ continue
643+
644+ if k in init_param_keys :
645+ init_params [k ] = v
646+ else :
647+ model_config [k ] = v
648+
642649 if agent_name == Agents .task_agent :
643650 model_config ["stream" ] = True
644651 if agent_name == Agents .search_agent :
645652 try :
646653 model_platform_enum = ModelPlatformType (options .model_platform .lower ())
654+ if model_platform_enum in {
655+ ModelPlatformType .OPENAI ,
656+ ModelPlatformType .AZURE ,
657+ ModelPlatformType .AIHUBMIX ,
658+ }:
659+ model_config ["parallel_tool_calls" ] = False
647660 except (ValueError , AttributeError ):
661+ traceroot_logger .error (f"Invalid model platform for search agent: { options .model_platform } " , exc_info = True )
648662 model_platform_enum = None
649- if model_platform_enum in {
650- ModelPlatformType .OPENAI ,
651- ModelPlatformType .AZURE ,
652- ModelPlatformType .AIHUBMIX ,
653- }:
654- model_config ["parallel_tool_calls" ] = False
655-
656663
657664 return ListenChatAgent (
658665 options .project_id ,
0 commit comments