Skip to content

feat(server-ai): stamp modelKey and modelVersion on AI usage events (…#308

Open
atornsii wants to merge 4 commits into
mainfrom
atornsii/AIC-2856/net-add-model-key-version
Open

feat(server-ai): stamp modelKey and modelVersion on AI usage events (…#308
atornsii wants to merge 4 commits into
mainfrom
atornsii/AIC-2856/net-add-model-key-version

Conversation

@atornsii

@atornsii atornsii commented Jul 8, 2026

Copy link
Copy Markdown

…AIC-2856)

Read modelKey and modelVersion from the AI Config variation payload and stamp them on all LdAiConfigTracker metric event payloads alongside existing modelName/providerName fields.

  • Add ModelKey/ModelVersion to ModelConfig
  • Parse new fields from variation payload in ConfigFactory
  • Include modelVersion unconditionally (default 1) and modelKey when non-empty in track data; exclude both from resumption token
  • Additive/backward compatible — older payloads without the new fields continue to work

Part of AIC-2849. Depends on AIC-2876 (backend payload).

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

Related issues

Provide links to any issues in this repository or elsewhere relating to this pull request.

Describe the solution you've provided

Provide a clear and concise description of what you expect to happen.

Describe alternatives you've considered

Provide a clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context about the pull request here.


Note

Low Risk
Additive telemetry on existing track payloads with defaults for legacy flags and resumption tokens; no public API surface change beyond internal config fields.

Overview
Adds LaunchDarkly model identity (modelKey, modelVersion) from AI Config flag _ldMeta and threads it through completion, agent, and judge configs into LdAiConfigTracker metric payloads.

Parsing & config: ParseMeta reads modelKey / modelVersion from _ldMeta (not the model object so modelVersion isn’t confused with the LLM name/version). Missing modelVersion defaults to 1; caller defaults use modelKey: null and modelVersion: 1. New internal fields live on LdAiConfig, not ModelConfig.

Tracking: All tracker events include modelVersion; modelKey is added only when non-empty. Resumption tokens are unchanged—neither field is encoded; resumed trackers still get modelVersion 1 and no modelKey.

Tests cover flag parsing → TrackSuccess payloads and resumption defaults.

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

…AIC-2856)

Read modelKey and modelVersion from the AI Config variation payload and stamp
them on all LdAiConfigTracker metric event payloads alongside existing
modelName/providerName fields.

- Add ModelKey/ModelVersion to ModelConfig
- Parse new fields from variation payload in ConfigFactory
- Include modelVersion unconditionally (default 1) and modelKey when non-empty
  in track data; exclude both from resumption token
- Additive/backward compatible — older payloads without the new fields continue
  to work

Part of AIC-2849. Depends on AIC-2876 (backend payload).

Co-authored-by: Anthony Torns II <atornsii@users.noreply.github.com>
@jsonbailey

Copy link
Copy Markdown
Contributor

Holding based on our conversation today and we will follow up on slack before reviewing.

@atornsii
atornsii marked this pull request as ready for review July 9, 2026 20:32
@atornsii
atornsii requested a review from a team as a code owner July 9, 2026 20:32
@atornsii
atornsii marked this pull request as draft July 15, 2026 21:36
Gonfalon moved these two fields from the payload's model object to
_ldMeta (launchdarkly/gonfalon#67230) to avoid modelVersion reading as
the underlying LLM's own version. Field names are unchanged; only the
JSON location moves. ModelConfig's public properties and the tracker's
stamped event fields are untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@atornsii
atornsii marked this pull request as ready for review July 16, 2026 16:55
var parameters = LdValueObjectToDictionary(modelValue.Get("parameters"));
var custom = LdValueObjectToDictionary(modelValue.Get("custom"));
return new LdAiConfigTypes.ModelConfig(name, parameters, custom);
var meta = value.Get("_ldMeta");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this should be part of the parse model method. We already have a parse meta method. Maybe that needs to be refactored to return an object instead of the individual parameters, but it shouldn't be part of the model object like we do here.

atornsii and others added 2 commits July 16, 2026 14:39
Per review: ParseModel reaching into _ldMeta mixed concerns — it should
only parse the model object. ParseMeta now returns a Meta record struct
(replacing the 4-field tuple) that also carries ModelKey/ModelVersion,
and callers pass those into ParseModel as plain parameters instead of
letting it fetch _ldMeta itself. No behavior change; 242/242 tests pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Per follow-up discussion: modelKey/modelVersion shouldn't be exposed on
the model object a client sees at all — they'd read as properties of
the model itself (e.g. a version like "5.4") rather than LaunchDarkly
tracking metadata. They now live only where variationKey/version
already live: as internal-only fields on LdAiConfig, passed straight
into the tracker factory. ModelConfig, ParseModel, and the *ConfigDefault
constructors go back to carrying only name/parameters/custom.

Tests that asserted Model.ModelKey/ModelVersion are replaced with
tracker-level assertions (mirroring the existing modelKey-present test);
the "absent from payload" case now verifies via the tracker too.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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