feat(server-ai): stamp modelKey and modelVersion on AI usage events (AIC-2858)#1794
Conversation
…AIC-2858) Read modelKey and modelVersion from the AI Config variation payload and stamp them on emitted metric events alongside existing modelName and providerName fields. Default modelVersion to 1 when absent and exclude both fields from the resumption token. Additive and backward compatible. Co-authored-by: Anthony Torns II <atornsii@users.noreply.github.com>
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/browser size report |
|
Holding based on our conversation today and we will follow up on slack before reviewing. |
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. _toBaseConfig now merges modelKey/modelVersion from _ldMeta onto the exposed model object (previously a direct passthrough of flagValue.model, which no longer carries them), only setting them when actually present so config.model's shape is unchanged when they're absent. The tracker's own default-to-1 fallback for stamped events is untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8ad1db9. Configure here.
modelKey/modelVersion should only be visible via the tracker's stamped event data, mirroring how variationKey/version are treated. LDAIClientImpl already sourced them from _ldMeta directly for the tracker factory, so only the model reconstruction in _toBaseConfig needed to stop merging them onto the public model object. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Requirements
Related issues
Describe the solution you've provided
Read
modelKeyandmodelVersionfrom the AI Config variation payload (variation.model) and stamp them on allLDAIConfigTrackermetric event payloads, alongside existingmodelName/providerNamefields.modelKey/modelVersiontoLDModelConfigLDAIConfigTrackerImplfromLDAIClientImpl._evaluatemodelVersion(always) andmodelKey(when present) ingetTrackData()modelVersionto1when absent; exclude both fields from the resumption tokenDescribe alternatives you've considered
None — this mirrors the established pattern from the Go and Python SDK implementations.
Additional context
Tech spec: Models Primitive Improvements
Test plan
yarn workspace @launchdarkly/server-sdk-ai test(241 passed)yarn workspace @launchdarkly/server-sdk-ai lintyarn workspaces foreach -pR --topological-dev --from '@launchdarkly/server-sdk-ai' run build