feat!: Split track_metrics_of into sync and async variants (PR-4.5)#112
Merged
jsonbailey merged 6 commits intomainfrom Mar 26, 2026
Merged
feat!: Split track_metrics_of into sync and async variants (PR-4.5)#112jsonbailey merged 6 commits intomainfrom
jsonbailey merged 6 commits intomainfrom
Conversation
packages/ai-providers/server-ai-openai/src/ldai_openai/openai_helper.py
Outdated
Show resolved
Hide resolved
keelerm84
approved these changes
Mar 26, 2026
packages/ai-providers/server-ai-langchain/src/ldai_langchain/langchain_helper.py
Outdated
Show resolved
Hide resolved
packages/ai-providers/server-ai-openai/src/ldai_openai/openai_helper.py
Outdated
Show resolved
Hide resolved
e2df180 to
ff3022e
Compare
…sync) variants feat: add optional graph_key to all LDAIConfigTracker track_* methods for graph correlation feat: add track_tool_call/track_tool_calls to LDAIConfigTracker feat: add graph_key property to AIGraphTracker feat: make AIGraphTracker.track_total_tokens accept Optional[TokenUsage], skip when None or total <= 0 feat: add LangChainHelper.get_tool_calls_from_response and sum_token_usage_from_messages feat: extract OpenAIHelper.get_ai_usage_from_response; delegate get_ai_metrics_from_response to it refactor: remove node-scoped methods from AIGraphTracker (track_node_invocation, track_tool_call, track_node_judge_response) refactor: use time.time_ns() for sub-millisecond precision in duration calculations
…ration measurement perf_counter_ns is monotonic and designed for elapsed-time measurement; time.time_ns reflects wall-clock time and can go backward due to NTP or clock adjustments.
886e3b7 to
a183f12
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
packages/ai-providers/server-ai-langchain/src/ldai_langchain/langchain_helper.py
Show resolved
Hide resolved
…ance check Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sages; add tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

feat: Add optional graph_key to all LDAIConfigTracker track_* methods for graph correlation
feat: Add track_tool_call/track_tool_calls to LDAIConfigTracker
fix: make AIGraphTracker.track_total_tokens accept Optional[TokenUsage], skip when None or total <= 0
feat: Add get_tool_calls_from_response and sum_token_usage_from_messages to langchain_helper
feat: Add get_ai_usage_from_response to openai_helper
fix!: Remove node-scoped methods from AIGraphTracker (track_node_invocation, track_tool_call, track_node_judge_response), use related AIConfigTracker methods instead
fix: use time.perf_counter_ns() for sub-millisecond precision in duration calculations
Note
Medium Risk
Breaking API change to
LDAIConfigTracker.track_metrics_of(now sync) and widespread call-site updates; also changes event payloads/metrics emission by adding optionalgraph_keyand new tool-call events, which could affect analytics and integrations.Overview
Breaks and reshapes tracking API:
LDAIConfigTracker.track_metrics_ofis now synchronous and a newtrack_metrics_of_asynchandles awaited operations; all internal usage (e.g.Judge,ManagedModel) and docs/examples are updated accordingly.Expands tracking payloads and capabilities: most
track_*methods accept optionalgraph_keyto correlate config-level events within graph runs, and newtrack_tool_call/track_tool_callsevents are added.AIGraphTrackeris simplified by removing node-scoped tracking helpers and makingtrack_total_tokensacceptOptional[TokenUsage](no-op when unknown/zero), and duration timing switches totime.perf_counter_ns()for better precision.LangChain utilities added: exports new helpers to extract tool call names (
get_tool_calls_from_response) and aggregate token usage across messages (sum_token_usage_from_messages), with accompanying tests.Written by Cursor Bugbot for commit cbcb5ae. This will update automatically on new commits. Configure here.