Skip to content

feat(server-ai): stamp modelKey and modelVersion on AI usage events (AIC-2858) - #1794

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

feat(server-ai): stamp modelKey and modelVersion on AI usage events (AIC-2858)#1794
atornsii merged 3 commits into
mainfrom
atornsii/AIC-2858/add-support-for-model-key-version

Conversation

@atornsii

@atornsii atornsii commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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

  • AIC-2858 — Make Changes to Node.js
  • Parent: AIC-2849 — Add modelKey and modelVersion as fields to be read by SDK
  • Depends on backend payload work: AIC-2876
  • Mirrors Go: AIC-2850 / Python: PR #208

Describe the solution you've provided

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

  • Add optional modelKey/modelVersion to LDModelConfig
  • Pass the new fields into LDAIConfigTrackerImpl from LDAIClientImpl._evaluate
  • Include modelVersion (always) and modelKey (when present) in getTrackData()
  • Default modelVersion to 1 when absent; exclude both fields from the resumption token
  • Additive/backward compatible — older payloads without the new fields continue to work

Describe 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 lint
  • yarn workspaces foreach -pR --topological-dev --from '@launchdarkly/server-sdk-ai' run build
  • Verify against a staging environment once AIC-2876 payload is available
Open in Web Open in Cursor 

…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>
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 26365 bytes
Compressed size limit: 29000
Uncompressed size: 129044 bytes

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 38887 bytes
Compressed size limit: 39000
Uncompressed size: 212703 bytes

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 32006 bytes
Compressed size limit: 34000
Uncompressed size: 114336 bytes

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 179727 bytes
Compressed size limit: 200000
Uncompressed size: 831515 bytes

@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
joker23
joker23 previously approved these changes Jul 10, 2026
@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.

_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>
@atornsii
atornsii marked this pull request as ready for review July 16, 2026 16:55

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread packages/sdk/server-ai/src/LDAIClientImpl.ts
Comment thread packages/sdk/server-ai/src/api/config/LDAIConfigUtils.ts Outdated
@joker23
joker23 self-requested a review July 16, 2026 17:22
@joker23
joker23 dismissed their stale review July 16, 2026 17:22

dismissing because approval is old

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>
@atornsii
atornsii merged commit a91a1e7 into main Jul 22, 2026
56 of 60 checks passed
@atornsii
atornsii deleted the atornsii/AIC-2858/add-support-for-model-key-version branch July 22, 2026 22:47
@github-actions github-actions Bot mentioned this pull request Jul 22, 2026
joker23 pushed a commit that referenced this pull request Jul 23, 2026
🤖 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>
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.

4 participants