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>
🤖 I have created a release *beep* *boop* --- <details><summary>browser: 0.1.30</summary> ## [0.1.30](browser-v0.1.29...browser-v0.1.30) (2026-07-22) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk bumped from 4.9.2 to 4.9.3 </details> <details><summary>client-testing-plugin: 1.0.6</summary> ## [1.0.6](client-testing-plugin-v1.0.5...client-testing-plugin-v1.0.6) (2026-07-22) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk-common bumped from 1.30.0 to 1.30.1 * devDependencies * @launchdarkly/js-client-sdk bumped from 4.9.2 to 4.9.3 * @launchdarkly/react-sdk bumped from 4.1.7 to 4.1.8 * peerDependencies * @launchdarkly/js-client-sdk bumped from ^4.9.1 to ^4.9.3 * @launchdarkly/react-sdk bumped from ^4.1.4 to ^4.1.8 </details> <details><summary>jest: 1.0.25</summary> ## [1.0.25](jest-v1.0.24...jest-v1.0.25) (2026-07-22) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/react-native-client-sdk bumped from ~10.19.2 to ~10.19.3 </details> <details><summary>js-client-sdk: 4.9.3</summary> ## [4.9.3](js-client-sdk-v4.9.2...js-client-sdk-v4.9.3) (2026-07-22) ### Bug Fixes * add defensive cycle guard to prerequisite evaluation ([#1816](#1816)) ([9426b42](9426b42)) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk-common bumped from 1.30.0 to 1.30.1 </details> <details><summary>js-client-sdk-common: 1.30.1</summary> ## [1.30.1](js-client-sdk-common-v1.30.0...js-client-sdk-common-v1.30.1) (2026-07-22) ### Bug Fixes * add defensive cycle guard to prerequisite evaluation ([#1816](#1816)) ([9426b42](9426b42)) </details> <details><summary>node-client-sdk: 0.4.3</summary> ## [0.4.3](node-client-sdk-v0.4.2...node-client-sdk-v0.4.3) (2026-07-22) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk-common bumped from 1.30.0 to 1.30.1 </details> <details><summary>react-native-client-sdk: 10.19.3</summary> ## [10.19.3](react-native-client-sdk-v10.19.2...react-native-client-sdk-v10.19.3) (2026-07-22) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk-common bumped from 1.30.0 to 1.30.1 </details> <details><summary>react-sdk: 4.1.8</summary> ## [4.1.8](react-sdk-v4.1.7...react-sdk-v4.1.8) (2026-07-22) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk bumped from ^4.9.2 to ^4.9.3 </details> <details><summary>server-sdk-ai: 1.3.0</summary> ## [1.3.0](server-sdk-ai-v1.2.3...server-sdk-ai-v1.3.0) (2026-07-22) ### Features * **server-ai:** stamp modelKey and modelVersion on AI usage events (AIC-2858) ([#1794](#1794)) ([a91a1e7](a91a1e7)) </details> <details><summary>server-sdk-ai-langchain: 0.8.8</summary> ## [0.8.8](server-sdk-ai-langchain-v0.8.7...server-sdk-ai-langchain-v0.8.8) (2026-07-22) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^1.2.3 to ^1.3.0 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^1.1.1 to ^1.3.0 </details> <details><summary>server-sdk-ai-openai: 0.7.8</summary> ## [0.7.8](server-sdk-ai-openai-v0.7.7...server-sdk-ai-openai-v0.7.8) (2026-07-22) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^1.2.3 to ^1.3.0 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^1.1.1 to ^1.3.0 </details> <details><summary>server-sdk-ai-vercel: 0.7.8</summary> ## [0.7.8](server-sdk-ai-vercel-v0.7.7...server-sdk-ai-vercel-v0.7.8) (2026-07-22) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^1.2.3 to ^1.3.0 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^1.1.1 to ^1.3.0 </details> <details><summary>vue-client-sdk: 0.1.3</summary> ## [0.1.3](vue-client-sdk-v0.1.2...vue-client-sdk-v0.1.3) (2026-07-22) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk bumped to 4.9.3 </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > The release carries a flag-evaluation behavior change (cycle handling) and AI telemetry shape changes; risk is moderate for apps with cyclic prerequisites or AI usage analytics, though the diff here is mostly versioning. > > **Overview** > This is a **Release Please** cut that bumps versions across the monorepo and refreshes changelogs, `.release-please-manifest.json`, workspace dependency pins, and embedded SDK version strings—no new application logic in the diff itself. > > **`@launchdarkly/js-client-sdk-common` 1.30.1** (pulled into browser, node-client, React Native, and related wrappers) documents a **defensive cycle guard during prerequisite flag evaluation**, avoiding unbounded recursion when prerequisite graphs contain cycles ([#1816](#1816)). > > **`@launchdarkly/server-sdk-ai` 1.3.0** adds **`modelKey` and `modelVersion` on AI usage / tracker events** from flag `_ldMeta` ([#1794](#1794)). LangChain, OpenAI, and Vercel AI provider packages are re-released with updated `server-sdk-ai` peer/dev dependencies only. > > Downstream packages (React, Vue, combined browser, client-testing-plugin, jest tooling, examples) are version-aligned to pick up the client-common fix transitively where applicable. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 35513d5. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.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