Skip to content

feat: add agent graph tracker#89

Open
andrewklatzke wants to merge 3 commits intomainfrom
aklatzke/REL-12055/agent-graph-tracking
Open

feat: add agent graph tracker#89
andrewklatzke wants to merge 3 commits intomainfrom
aklatzke/REL-12055/agent-graph-tracking

Conversation

@andrewklatzke
Copy link
Contributor

@andrewklatzke andrewklatzke commented Feb 5, 2026

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Describe the solution you've provided

Implements the AIGraphTracker class to handle tracking events for agent graphs in the SDK.

Describe alternatives you've considered

This is the primary implementation of the tracker. It's broken into its own tracker rather than polluting the interface of the BaseTracker or AiConfigTracker since this is a separate entity that has its own interaction & metric patterns.

Additional context

This implements the following events to be tracked:

Edge-level metrics

$ld:ai:graph:redirect<{ sourceKey, redirectedTarget }>
$ld:ai:graph:handoff_success<{ sourceKey, targetKey }>
$ld:ai:graph:handoff_failure<{ sourceKey, targetKey }>

Node level metrics

$ld:ai:graph:node_invocation<{ graphKey, configKey }>
$ld:ai:graph:tool_call<{ graphKey, configKey, toolKey }>
<judge_metrics><{ graphKey, configKey }> (judge on a specific node)

Graph metrics

$ld:ai:graph:invocation_success
$ld:ai:graph:invocation_failure
$ld:ai:graph:latency (total latency of the entire graph invocation)
$ld:ai:graph:total_tokens (total token usage of the graph invocation)
$ld:ai:graph:path<{ graphKey, ...configKey }>
<judge_metrics><{ graphKey }> (judges on final output)

Note

Medium Risk
Adds new analytics/event emission paths and changes agent_graph() return objects to always include a tracker, which could affect downstream behavior/telemetry volume but not core evaluation logic.

Overview
Adds a new AIGraphTracker with dedicated LaunchDarkly track events for agent-graph execution (graph invocation success/failure, latency, total tokens, execution path, node/tool invocations, redirects/handoffs, and judge metrics).

LDAIClient.agent_graph() now creates and attaches this tracker using flag _ldMeta (variation key/version) and returns it on AgentGraphDefinition via a new optional tracker field and get_tracker() accessor; AIGraphTracker is also exported from the package root.

Written by Cursor Bugbot for commit c6a09d0. This will update automatically on new commits. Configure here.

@andrewklatzke andrewklatzke requested a review from a team as a code owner February 5, 2026 00:53
@@ -1,11 +1,11 @@
"""Graph implementation for managing AI agent graphs."""

from dataclasses import dataclass
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unused import here, not sure why it wasn't picked up in previous lint

Co-authored-by: Jason Bailey <jbailey@launchdarkly.com>
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.

self._context,
track_data,
eval_score.score,
)
Copy link

Choose a reason for hiding this comment

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

Duplicated judge response tracking logic within same class

Low Severity

track_judge_response and track_node_judge_response within AIGraphTracker contain nearly identical logic — the only difference is that track_node_judge_response adds "configKey" to the track data. Extracting the shared eval-iteration logic into a private helper (accepting an optional config_key) would reduce duplication and the risk of the two methods drifting out of sync during future changes.

Additional Locations (1)

Fix in Cursor Fix in Web

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

Comments