fix: Add support for graph metric tracking#1269
fix: Add support for graph metric tracking#1269jsonbailey merged 2 commits intoai-sdk-next-releasefrom
Conversation
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>
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/browser size report |
|
@launchdarkly/js-client-sdk-common size report |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
JS looks good - will await @andrewklatzke's review |
Summary
LDGraphTrackerinterface andLDGraphTrackerImplfor tracking graph-level and edge-level metrics in AI agent graph operationsLDAIConfigTrackerwith optionalgraphKeyparameter on all tracking methods, enabling node-level events to carry graph contexttrackToolCall/trackToolCallsmethods toLDAIConfigTrackerChanges
New
LDGraphTrackerinterface (src/api/graph/LDGraphTracker.ts):trackInvocationSuccess,trackInvocationFailure,trackLatency,trackTotalTokens,trackPath,trackJudgeResponsetrackRedirect,trackHandoffSuccess,trackHandoffFailuregetSummary()returningLDGraphMetricSummaryUpdated
LDAIConfigTrackerinterface:graphKey?: stringparametertrackToolCall(toolKey, graphKey?)andtrackToolCalls(toolKeys, graphKey?)methodsgetTrackData(graphKey?)includesgraphKeyin the payload when providedSpec references: AIGRAPHTRACK, AITRACK
Python reference:
python-server-sdk-aimainTest plan
yarn workspace @launchdarkly/server-sdk-ai test)yarn workspace @launchdarkly/server-sdk-ai lint)LDGraphTrackerImpl.test.tscovers 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
LDGraphTrackerAPI andLDGraphTrackerImpl, emitting graph-level events (invocation success/failure, latency, total tokens, path, judge evals) plus edge events (redirects and handoffs) and exposing agetSummary()of captured graph metrics.Extends
LDAIConfigTracker/LDAIConfigTrackerImplso all existing tracking methods accept an optionalgraphKeyand include it in event payloads when provided, and adds newtrackToolCall/trackToolCallsmethods that emit$ld:ai:tool_callevents.Exports the new graph API from
src/apiand re-exportsLDGraphTrackerImplfrom the package entrypoint, with comprehensive new/updated unit tests coveringgraphKeypropagation, 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.