Skip to content

Commit 2dd9329

Browse files
committed
fix: merge duplicate track_tool_calls methods in LDAIConfigTracker
The new track_tool_calls method at line 413 (with summary storage and dedup guard) was being shadowed by the older method at line 559 (which only fired per-tool events). Merge them into a single method that both stores to the summary and fires per-tool events.
1 parent 4e28ae6 commit 2dd9329

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

packages/sdk/server-ai/src/ldai/tracker.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,22 @@ def track_feedback(self, feedback: Dict[str, FeedbackKind]) -> None:
410410
1,
411411
)
412412

413-
def track_tool_calls(self, tool_calls: List[str]) -> None:
413+
def track_tool_calls(self, tool_calls: Iterable[str]) -> None:
414414
"""
415415
Track the tool calls made during an AI operation.
416416
417-
:param tool_calls: List of tool call names.
417+
Stores the tool call names on the summary (guarding against duplicate
418+
tracking) and fires a ``$ld:ai:tool_call`` event for each tool.
419+
420+
:param tool_calls: Tool identifiers (e.g. from a model response).
418421
"""
419422
if self._summary.tool_calls is not None:
420423
log.warning("Tool calls have already been tracked for this execution. %s", self.__get_track_data())
421424
return
422-
self._summary._tool_calls = list(tool_calls)
425+
tool_calls_list = list(tool_calls)
426+
self._summary._tool_calls = tool_calls_list
427+
for tool_key in tool_calls_list:
428+
self.track_tool_call(tool_key)
423429

424430
def track_success(self) -> None:
425431
"""
@@ -556,15 +562,6 @@ def track_tool_call(self, tool_key: str) -> None:
556562
1,
557563
)
558564

559-
def track_tool_calls(self, tool_keys: Iterable[str]) -> None:
560-
"""
561-
Track multiple tool invocations for this configuration.
562-
563-
:param tool_keys: Tool identifiers (e.g. from a model response).
564-
"""
565-
for tool_key in tool_keys:
566-
self.track_tool_call(tool_key)
567-
568565
def get_summary(self) -> LDAIMetricSummary:
569566
"""
570567
Get the current summary of AI metrics.

0 commit comments

Comments
 (0)