Skip to content

feat!: Split track_metrics_of into sync and async variants (PR-4.5)#112

Merged
jsonbailey merged 6 commits intomainfrom
jb/aic-1664/graph-tracking-improvements
Mar 26, 2026
Merged

feat!: Split track_metrics_of into sync and async variants (PR-4.5)#112
jsonbailey merged 6 commits intomainfrom
jb/aic-1664/graph-tracking-improvements

Conversation

@jsonbailey
Copy link
Contributor

@jsonbailey jsonbailey commented Mar 25, 2026

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 optional graph_key and new tool-call events, which could affect analytics and integrations.

Overview
Breaks and reshapes tracking API: LDAIConfigTracker.track_metrics_of is now synchronous and a new track_metrics_of_async handles awaited operations; all internal usage (e.g. Judge, ManagedModel) and docs/examples are updated accordingly.

Expands tracking payloads and capabilities: most track_* methods accept optional graph_key to correlate config-level events within graph runs, and new track_tool_call/track_tool_calls events are added. AIGraphTracker is simplified by removing node-scoped tracking helpers and making track_total_tokens accept Optional[TokenUsage] (no-op when unknown/zero), and duration timing switches to time.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.

@jsonbailey jsonbailey marked this pull request as ready for review March 25, 2026 22:05
@jsonbailey jsonbailey requested a review from a team as a code owner March 25, 2026 22:05
@jsonbailey jsonbailey force-pushed the jb/aic-1664/runner-abcs branch from e2df180 to ff3022e Compare March 26, 2026 14:31
Base automatically changed from jb/aic-1664/runner-abcs to main March 26, 2026 17:27
…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.
@jsonbailey jsonbailey force-pushed the jb/aic-1664/graph-tracking-improvements branch from 886e3b7 to a183f12 Compare March 26, 2026 17:49
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

jsonbailey and others added 3 commits March 26, 2026 12:55
…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>
@jsonbailey jsonbailey merged commit 4fab18f into main Mar 26, 2026
46 checks passed
@jsonbailey jsonbailey deleted the jb/aic-1664/graph-tracking-improvements branch March 26, 2026 18:51
@github-actions github-actions bot mentioned this pull request Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants