Skip to content

fix: Add support for graph metric tracking#1269

Merged
jsonbailey merged 2 commits intoai-sdk-next-releasefrom
jb/aic-2186/add-graph-tracking
Apr 14, 2026
Merged

fix: Add support for graph metric tracking#1269
jsonbailey merged 2 commits intoai-sdk-next-releasefrom
jb/aic-2186/add-graph-tracking

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

@jsonbailey jsonbailey commented Apr 13, 2026

Summary

  • Introduces LDGraphTracker interface and LDGraphTrackerImpl for tracking graph-level and edge-level metrics in AI agent graph operations
  • Extends LDAIConfigTracker with optional graphKey parameter on all tracking methods, enabling node-level events to carry graph context
  • Adds trackToolCall / trackToolCalls methods to LDAIConfigTracker
  • Implements at-most-once semantics for graph-level metrics (invocation success/failure, latency, total tokens, path); edge-level methods (redirect, handoff) are multi-fire

Changes

New LDGraphTracker interface (src/api/graph/LDGraphTracker.ts):

  • Graph-level: trackInvocationSuccess, trackInvocationFailure, trackLatency, trackTotalTokens, trackPath, trackJudgeResponse
  • Edge-level: trackRedirect, trackHandoffSuccess, trackHandoffFailure
  • getSummary() returning LDGraphMetricSummary

Updated LDAIConfigTracker interface:

  • All tracking methods accept an optional graphKey?: string parameter
  • New trackToolCall(toolKey, graphKey?) and trackToolCalls(toolKeys, graphKey?) methods
  • getTrackData(graphKey?) includes graphKey in the payload when provided

Spec references: AIGRAPHTRACK, AITRACK
Python reference: python-server-sdk-ai main

Test plan

  • All 125 existing + new tests pass (yarn workspace @launchdarkly/server-sdk-ai test)
  • Lint clean (yarn workspace @launchdarkly/server-sdk-ai lint)
  • New LDGraphTrackerImpl.test.ts covers all graph tracking methods, at-most-once semantics, and edge-level multi-fire behavior

🤖 Generated with Claude Code


Note

Medium Risk
Expands the public tracking API (LDAIConfigTracker) and introduces new tracking events, which could affect downstream consumers and event volume/shape if adopted; changes are contained to metrics/tracking code paths.

Overview
Adds first-class agent graph metric tracking via a new LDGraphTracker API and LDGraphTrackerImpl, emitting graph-level events (invocation success/failure, latency, total tokens, path, judge evals) plus edge events (redirects and handoffs) and exposing a getSummary() of captured graph metrics.

Extends LDAIConfigTracker/LDAIConfigTrackerImpl so all existing tracking methods accept an optional graphKey and include it in event payloads when provided, and adds new trackToolCall/trackToolCalls methods that emit $ld:ai:tool_call events.

Exports the new graph API from src/api and re-exports LDGraphTrackerImpl from the package entrypoint, with comprehensive new/updated unit tests covering graphKey propagation, tool-call tracking, and at-most-once semantics for graph-level metrics.

Reviewed by Cursor Bugbot for commit c5111a4. Bugbot is set up for automated code reviews on this repo. Configure here.

Introduces LDGraphTracker (and LDGraphTrackerImpl) for tracking graph-level
and edge-level metrics in AI agent graph operations. Also extends
LDAIConfigTracker with optional graphKey parameter support on all tracking
methods, plus new trackToolCall/trackToolCalls methods, matching the
AIGRAPHTRACK and AITRACK spec updates.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25623 bytes
Compressed size limit: 29000
Uncompressed size: 125843 bytes

@github-actions
Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 31649 bytes
Compressed size limit: 34000
Uncompressed size: 112792 bytes

@github-actions
Copy link
Copy Markdown
Contributor

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 179372 bytes
Compressed size limit: 200000
Uncompressed size: 829982 bytes

@github-actions
Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 37169 bytes
Compressed size limit: 38000
Uncompressed size: 204305 bytes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey jsonbailey marked this pull request as ready for review April 14, 2026 14:39
@jsonbailey jsonbailey requested a review from a team as a code owner April 14, 2026 14:39
@joker23
Copy link
Copy Markdown
Contributor

joker23 commented Apr 14, 2026

JS looks good - will await @andrewklatzke's review

@jsonbailey jsonbailey changed the base branch from main to ai-sdk-next-release April 14, 2026 21:45
@jsonbailey jsonbailey merged commit 7745852 into ai-sdk-next-release Apr 14, 2026
45 checks passed
@jsonbailey jsonbailey deleted the jb/aic-2186/add-graph-tracking branch April 14, 2026 21:46
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.

3 participants