Skip to content

docs: Clarify runId purpose and per-method tracker semantics#1378

Merged
jsonbailey merged 3 commits into
mainfrom
jb/aic-2207/clarify-runid-docs
May 14, 2026
Merged

docs: Clarify runId purpose and per-method tracker semantics#1378
jsonbailey merged 3 commits into
mainfrom
jb/aic-2207/clarify-runid-docs

Conversation

@jsonbailey

@jsonbailey jsonbailey commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to the recently-merged billing-spec alignment PR for js-core's server-ai package. Brings tracker docs and at-most-once warning strings in line with what just landed for the Go SDK in launchdarkly/go-server-sdk#363.

  • refactor: commit: Reword the at-most-once warning messages on LDAIConfigTracker and LDGraphTracker so each one names the method being skipped, what was already recorded, and the remedy (call createTracker on the AI Config / agent graph for a new run).
  • docs: commit:
    • Expand class-level TSDoc on LDAIConfigTracker and LDGraphTracker to explain that the runId is what LaunchDarkly uses to correlate a tracker's events in metrics views, and that the resumption token preserves the runId across process boundaries.
    • Expand LDAIConfig.createTracker and AgentGraphDefinition.createTracker TSDoc with the same runId framing.
    • On each track* method, state at-most-once vs. multi-call semantics and what happens when the limit is hit. trackSuccess / trackError share state; the docstring on each says so. Wrapper methods (trackDurationOf, trackMetricsOf, trackStreamMetricsOf, trackBedrockConverseMetrics) note that calling the wrapper twice runs the inner function again but emits no additional metric events.
    • Fix stale completionConfig / agentConfig / judgeConfig / agentConfigs TSDoc and examples that still described a returned { config, messages, tracker } shape. The actual return is the config object with a createTracker() factory; examples now reflect this.
    • Light terminology sweep in narrative TSDoc text: prefer "AI run" / "graph run" over "execution" / "invocation" when referring to a single tracker's lifetime. Public API names (methods, event keys, type names, parameter names like executionContext) are unchanged.

No behavior changes, no version / changelog edits.

Test plan

  • CI passes on this branch.
  • LDAIConfigTrackerImpl and LDGraphTrackerImpl unit tests still pass (the two warning-text assertions were updated to match the new wording).

Note

Low Risk
Low risk: changes are limited to TSDoc/example updates and rewording warning log messages; no tracking behavior or event payloads change, but any consumers depending on exact warning text may be affected.

Overview
Clarifies tracker semantics across LDAIConfigTracker/LDGraphTracker and related APIs by explicitly framing a tracker as one AI/graph run whose events share a runId, and documenting at-most-once vs multi-call behavior per track* method (including wrapper helpers).

Standardizes at-most-once warning messages in LDAIConfigTrackerImpl and LDGraphTrackerImpl to name the skipped method, what was already recorded, and the remedy (call createTracker() for a new run), and updates unit tests accordingly. Also refreshes LDAIClient doc examples to reflect the createTracker() factory on returned configs rather than a returned tracker field.

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

jsonbailey and others added 2 commits May 13, 2026 11:31
Reword the at-most-once warning messages emitted by LDAIConfigTracker and
LDGraphTracker so each warning names the method being skipped, the thing
that was already recorded, and the remedy (call createTracker for a new
run). Aligns with the wording recently landed for the Go SDK.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Expand class- and method-level TSDoc on LDAIConfigTracker, LDGraphTracker,
LDAIConfig.createTracker, AgentGraphDefinition.createTracker, and the AI
client config-fetch methods so that:

- The role of the runId (UUIDv4 shared by all events from one tracker so
  LaunchDarkly can correlate them in metrics views) is stated up front.
- Each per-method docstring states whether the metric is at-most-once or
  multi-call, and what happens when the at-most-once guarantee is hit.
- completionConfig / agentConfig / judgeConfig examples reflect the actual
  return shape (the returned object IS the config, with a createTracker()
  factory) instead of the stale `{ config, messages, tracker }` shape.
- Narrative text refers to "AI run" or "graph run" rather than
  "execution" / "invocation" where those mean a single tracker's lifetime.
  Public API names (methods, event keys, type names, parameter names) are
  unchanged.

Aligns with the wording recently landed for the Go SDK.

Co-Authored-By: Claude Opus 4.7 (1M context) <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: 26208 bytes
Compressed size limit: 29000
Uncompressed size: 128789 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: 31906 bytes
Compressed size limit: 34000
Uncompressed size: 113658 bytes

@github-actions

Copy link
Copy Markdown
Contributor

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 179498 bytes
Compressed size limit: 200000
Uncompressed size: 830837 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: 38487 bytes
Compressed size limit: 39000
Uncompressed size: 211236 bytes

Replace "original run's runId" with "original tracker's runId" on
LDAIClient.createTracker so the doc no longer juxtaposes "run" and
"runId".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jsonbailey jsonbailey marked this pull request as ready for review May 13, 2026 17:47
@jsonbailey jsonbailey requested a review from a team as a code owner May 13, 2026 17:47
Comment thread packages/sdk/server-ai/__tests__/LDAIConfigTrackerImpl.test.ts
@jsonbailey jsonbailey merged commit a33b9ef into main May 14, 2026
43 checks passed
@jsonbailey jsonbailey deleted the jb/aic-2207/clarify-runid-docs branch May 14, 2026 13:42
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