Skip to content

feat(ldai): stamp modelKey and modelVersion on AI usage events (AIC-2850)#414

Merged
atornsii merged 3 commits into
v7from
atornsii/AIC-2850/add-support-for-model-key-version
Jul 22, 2026
Merged

feat(ldai): stamp modelKey and modelVersion on AI usage events (AIC-2850)#414
atornsii merged 3 commits into
v7from
atornsii/AIC-2850/add-support-for-model-key-version

Conversation

@atornsii

@atornsii atornsii commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Read modelKey and modelVersion from the AI Config variation payload (model.modelKey / model.modelVersion) and expose them on Config via ModelKey() / ModelVersion() accessors and builder methods
  • Stamp modelKey (when present) and modelVersion on all Tracker metric event payloads, alongside existing modelName/providerName fields
  • Default modelVersion to 1 when absent, matching variation version handling; exclude both fields from the resumption token
  • Additive/backward compatible — older payloads without the new fields continue to work

Part of AIC-2850 / AIC-2849. Depends on backend payload work (AIC-2876) shipping modelKey/modelVersion on variations.

Test plan

  • go build ./... in ldai/
  • go vet ./... in ldai/
  • go test ./... in ldai/ (all passed)
  • Verify against a staging environment once AIC-2876 payload is available

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

Describe the solution you've provided

The Go AI SDK now parses modelKey and modelVersion from the variation's model object, exposes them through Config accessors, and includes them in the trackData stamped on every metric event. modelVersion is always emitted (defaulting to 1); modelKey is omitted when empty. Neither field is included in the resumption token.

Describe alternatives you've considered

Threading modelKey/modelVersion as explicit constructor parameters to newTracker (as in the Python SDK PR) was considered but rejected in favor of sourcing from Config, matching the existing modelName/providerName pattern.

Additional context

Mirrors python-server-sdk-ai#208.

Open in Web Open in Cursor 

…850)

Read modelKey and modelVersion from the AI Config variation payload and expose
them on Config. Stamp both fields on every metric event alongside existing
modelName and providerName. modelVersion defaults to 1 when absent; modelKey is
omitted when empty. Neither field is included in the resumption token.

Additive and backward compatible with older payloads.

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.

@jsonbailey

Copy link
Copy Markdown
Contributor

We are also in the process of migrating this to the go-server-sdk-ai repository.

@atornsii
atornsii marked this pull request as ready for review July 9, 2026 20:31
@atornsii
atornsii requested a review from a team as a code owner July 9, 2026 20:31
@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. The SDK's public Config.ModelKey()/ModelVersion()
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
Comment thread ldai/tracker.go Outdated
Set("modelName", ldvalue.String(config.ModelName()))
Set("modelName", ldvalue.String(config.ModelName())).
Set("modelVersion", ldvalue.Int(config.ModelVersion()))
if config.ModelKey() != "" {

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.

should we exclude the modelVersion if the model key is empty? Wrap them both in the if check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No we want modelVersion to default to 1, meaning "unversioned model," whenever the key isn't present. We have legacy models and inline models attached that won't have a key

modelKey/modelVersion should only be visible via the tracker's stamped
event data, mirroring how VariationKey/Version are treated. They now
flow from the already-parsed _ldMeta fields straight into newTracker
as explicit parameters instead of being read off Config.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@atornsii
atornsii merged commit bd4ce7a into v7 Jul 22, 2026
32 checks passed
@atornsii
atornsii deleted the atornsii/AIC-2850/add-support-for-model-key-version branch July 22, 2026 22:47
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