2525 LDMessage ,
2626 ModelConfig ,
2727 ProviderConfig ,
28+ ToolDefinition ,
2829)
2930from ldai .providers import ToolRegistry
3031from ldai .providers .runner_factory import RunnerFactory
@@ -68,7 +69,7 @@ def _completion_config(
6869 default : AICompletionConfigDefault ,
6970 variables : Optional [Dict [str , Any ]] = None ,
7071 ) -> AICompletionConfig :
71- model , provider , messages , instructions , tracker , enabled , judge_configuration , _ = self .__evaluate (
72+ model , provider , messages , instructions , tracker , enabled , judge_configuration , _ , tools = self .__evaluate (
7273 key , context , default .to_dict (), variables
7374 )
7475
@@ -80,6 +81,7 @@ def _completion_config(
8081 provider = provider ,
8182 tracker = tracker ,
8283 judge_configuration = judge_configuration ,
84+ tools = tools ,
8385 )
8486
8587 return config
@@ -134,7 +136,9 @@ def _judge_config(
134136 default : AIJudgeConfigDefault ,
135137 variables : Optional [Dict [str , Any ]] = None ,
136138 ) -> AIJudgeConfig :
137- model , provider , messages , instructions , tracker , enabled , judge_configuration , variation = self .__evaluate (
139+ (model , provider , messages , instructions ,
140+ tracker , enabled , judge_configuration ,
141+ variation , tools ) = self .__evaluate (
138142 key , context , default .to_dict (), variables
139143 )
140144
@@ -750,7 +754,8 @@ def __evaluate(
750754 variables : Optional [Dict [str , Any ]] = None ,
751755 ) -> Tuple [
752756 Optional [ModelConfig ], Optional [ProviderConfig ], Optional [List [LDMessage ]],
753- Optional [str ], LDAIConfigTracker , bool , Optional [Any ], Dict [str , Any ]
757+ Optional [str ], LDAIConfigTracker , bool , Optional [Any ], Dict [str , Any ],
758+ Optional [List [ToolDefinition ]]
754759 ]:
755760 """
756761 Internal method to evaluate a configuration and extract components.
@@ -828,7 +833,23 @@ def __evaluate(
828833 if judges :
829834 judge_configuration = JudgeConfiguration (judges = judges )
830835
831- return model , provider_config , messages , instructions , tracker , enabled , judge_configuration , variation
836+ tools = None
837+ model_raw = variation .get ('model' )
838+ params_raw = model_raw .get ('parameters' ) if isinstance (model_raw , dict ) else None
839+ tool_defs_raw = params_raw .get ('tools' ) if isinstance (params_raw , dict ) else None
840+ if isinstance (tool_defs_raw , list ):
841+ tools = [
842+ ToolDefinition (
843+ name = t .get ('name' , '' ),
844+ parameters = t .get ('parameters' , None )
845+ )
846+ for t in tool_defs_raw
847+ if isinstance (t , dict ) and t .get ('name' )
848+ ]
849+ if not tools :
850+ tools = None
851+
852+ return model , provider_config , messages , instructions , tracker , enabled , judge_configuration , variation , tools
832853
833854 def __evaluate_agent (
834855 self ,
@@ -846,7 +867,7 @@ def __evaluate_agent(
846867 :param variables: Variables for interpolation.
847868 :return: Configured AIAgentConfig instance.
848869 """
849- model , provider , messages , instructions , tracker , enabled , judge_configuration , _ = self .__evaluate (
870+ model , provider , messages , instructions , tracker , enabled , judge_configuration , _ , tools = self .__evaluate (
850871 key , context , default .to_dict (), variables
851872 )
852873
@@ -861,6 +882,7 @@ def __evaluate_agent(
861882 instructions = final_instructions ,
862883 tracker = tracker ,
863884 judge_configuration = judge_configuration or default .judge_configuration ,
885+ tools = tools or default .tools ,
864886 )
865887
866888 def __interpolate_template (self , template : str , variables : Dict [str , Any ]) -> str :
0 commit comments