@@ -84,7 +84,7 @@ def _completion_config(
8484 default : AICompletionConfigDefault ,
8585 variables : Optional [Dict [str , Any ]] = None ,
8686 ) -> AICompletionConfig :
87- (model , provider , messages , instructions , tracker ,
87+ (model , provider , messages , instructions ,
8888 tracker_factory , enabled , judge_configuration , _ ) = self .__evaluate (
8989 key , context , default .to_dict (), variables
9090 )
@@ -95,7 +95,6 @@ def _completion_config(
9595 model = model ,
9696 messages = messages ,
9797 provider = provider ,
98- tracker = tracker ,
9998 create_tracker = tracker_factory ,
10099 judge_configuration = judge_configuration ,
101100 )
@@ -152,7 +151,7 @@ def _judge_config(
152151 default : AIJudgeConfigDefault ,
153152 variables : Optional [Dict [str , Any ]] = None ,
154153 ) -> AIJudgeConfig :
155- (model , provider , messages , instructions , tracker ,
154+ (model , provider , messages , instructions ,
156155 tracker_factory , enabled , judge_configuration , variation ) = self .__evaluate (
157156 key , context , default .to_dict (), variables
158157 )
@@ -181,7 +180,6 @@ def _extract_evaluation_metric_key(variation: Dict[str, Any]) -> Optional[str]:
181180 model = model ,
182181 messages = messages ,
183182 provider = provider ,
184- tracker = tracker ,
185183 create_tracker = tracker_factory ,
186184 )
187185
@@ -381,7 +379,7 @@ async def create_model(
381379 default_ai_provider ,
382380 )
383381
384- return ManagedModel (config , config . create_tracker (), runner , judges )
382+ return ManagedModel (config , runner , judges )
385383
386384 async def create_chat (
387385 self ,
@@ -455,7 +453,7 @@ async def create_agent(
455453 if not runner :
456454 return None
457455
458- return ManagedAgent (config , config . create_tracker (), runner )
456+ return ManagedAgent (config , runner )
459457
460458 def agent_config (
461459 self ,
@@ -485,7 +483,8 @@ def agent_config(
485483
486484 if agent.enabled:
487485 research_result = agent.instructions # Interpolated instructions
488- agent.tracker.track_success()
486+ tracker = agent.create_tracker()
487+ tracker.track_success()
489488
490489 :param key: The agent configuration key.
491490 :param context: The context to evaluate the agent configuration in.
@@ -555,7 +554,8 @@ def agent_configs(
555554 ], context)
556555
557556 research_result = agents["research_agent"].instructions
558- agents["research_agent"].tracker.track_success()
557+ tracker = agents["research_agent"].create_tracker()
558+ tracker.track_success()
559559
560560 :param agent_configs: List of agent configurations to retrieve.
561561 :param context: The context to evaluate the agent configurations in.
@@ -774,7 +774,7 @@ def __evaluate(
774774 graph_key : Optional [str ] = None ,
775775 ) -> Tuple [
776776 Optional [ModelConfig ], Optional [ProviderConfig ], Optional [List [LDMessage ]],
777- Optional [str ], LDAIConfigTracker , Callable [[], LDAIConfigTracker ], bool , Optional [Any ], Dict [str , Any ]
777+ Optional [str ], Callable [[], LDAIConfigTracker ], bool , Optional [Any ], Dict [str , Any ]
778778 ]:
779779 """
780780 Internal method to evaluate a configuration and extract components.
@@ -784,7 +784,8 @@ def __evaluate(
784784 :param default_dict: Default configuration as dictionary.
785785 :param variables: Variables for interpolation.
786786 :param graph_key: When set, passed to the tracker so all events include ``graphKey``.
787- :return: Tuple of (model, provider, messages, instructions, tracker, enabled, judge_configuration, variation).
787+ :return: Tuple of (model, provider, messages, instructions,
788+ tracker_factory, enabled, judge_configuration, variation).
788789 """
789790 variation = self ._client .variation (key , context , default_dict )
790791
@@ -844,8 +845,6 @@ def tracker_factory() -> LDAIConfigTracker:
844845 graph_key = graph_key ,
845846 )
846847
847- tracker = tracker_factory ()
848-
849848 enabled = variation .get ('_ldMeta' , {}).get ('enabled' , False )
850849
851850 judge_configuration = None
@@ -864,7 +863,7 @@ def tracker_factory() -> LDAIConfigTracker:
864863 judge_configuration = JudgeConfiguration (judges = judges )
865864
866865 return (
867- model , provider_config , messages , instructions , tracker ,
866+ model , provider_config , messages , instructions ,
868867 tracker_factory , enabled , judge_configuration , variation ,
869868 )
870869
@@ -886,7 +885,7 @@ def __evaluate_agent(
886885 :param graph_key: When set, passed to the tracker so all events include ``graphKey``.
887886 :return: Configured AIAgentConfig instance.
888887 """
889- (model , provider , messages , instructions , tracker ,
888+ (model , provider , messages , instructions ,
890889 tracker_factory , enabled , judge_configuration , _ ) = self .__evaluate (
891890 key , context , default .to_dict (), variables , graph_key = graph_key
892891 )
@@ -900,7 +899,6 @@ def __evaluate_agent(
900899 model = model or default .model ,
901900 provider = provider or default .provider ,
902901 instructions = final_instructions ,
903- tracker = tracker ,
904902 create_tracker = tracker_factory ,
905903 judge_configuration = judge_configuration or default .judge_configuration ,
906904 )
0 commit comments