Skip to content

feat: add graphKey support to tracker events and resumption tokens#10

Open
mattrmc1 wants to merge 1 commit into
mainfrom
mmccarthy/AIC-2928/go-sdk-aitrack-tracker
Open

feat: add graphKey support to tracker events and resumption tokens#10
mattrmc1 wants to merge 1 commit into
mainfrom
mmccarthy/AIC-2928/go-sdk-aitrack-tracker

Conversation

@mattrmc1

@mattrmc1 mattrmc1 commented Jul 7, 2026

Copy link
Copy Markdown

Summary

Extends Tracker with an optional graphKey parameter. When non-empty, graphKey is included in every event's trackData and in the resumption token. When empty, it is omitted entirely. This is the foundation for agent-graph node trackers (Task 06), where each node's tracker carries the containing graph's key.

Tracker construction

newTracker and newTrackerWithStopwatch gain a graphKey string parameter (last positional arg). The graphKey is stored on the Tracker struct and conditionally added to trackData:

if graphKey != "" {
    builder.Set("graphKey", ldvalue.String(graphKey))
}

All existing call sites in client.go (returnDefault and evaluateConfig) pass "", so current behavior is unchanged.

Resumption token

resumptionPayload gains a GraphKey field with json:"graphKey,omitempty":

type resumptionPayload struct {
    RunID        string `json:"runId"`
    ConfigKey    string `json:"configKey"`
    VariationKey string `json:"variationKey,omitempty"`
    Version      int    `json:"version"`
    GraphKey     string `json:"graphKey,omitempty"`
}

TrackerFromResumptionToken reads graphKey from the decoded payload and passes it through to the reconstructed tracker.

Test plan

  • go test -race ./... passes
  • Tracker with graphKey="my-graph" — every emitted event (success, duration, tokens, etc.) includes "graphKey":"my-graph" in data
  • Tracker with graphKey=""graphKey key absent from trackData entirely (not present as empty string)
  • Resumption token with graphKey — decoded JSON contains "graphKey":"my-graph"
  • Resumption token without graphKey — graphKey key absent from JSON
  • TrackerFromResumptionToken with graphKey — reconstructed tracker emits events with graphKey and produces an identical resumption token
  • Client.CreateTracker round-trip with graphKey — token survives client-level reconstruction, events include graphKey
  • All existing tracker tests pass unchanged (graphKey "" everywhere)

Note

Low Risk
Additive optional metadata on existing tracker APIs; default call sites unchanged and covered by tests for token round-trip and event payloads.

Overview
Adds an optional graphKey on internal Tracker construction so agent-graph node runs can tag analytics with the parent graph. When set, graphKey is included in shared trackData for all metric events and in ResumptionToken JSON (omitempty); when empty, the field is omitted entirely.

TrackerFromResumptionToken and Client.CreateTracker round-trips preserve graphKey. Config-driven tracker factories in client.go still pass "", so completion/judge configs behave as before until graph node code supplies a key.

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

@mattrmc1 mattrmc1 marked this pull request as ready for review July 7, 2026 16:15
@mattrmc1 mattrmc1 requested review from a team as code owners July 7, 2026 16:15
@mattrmc1 mattrmc1 requested a review from jsonbailey July 8, 2026 20:53
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