Skip to content

feat: fall back to model.parameters.tools when root tools absent#1330

Merged
jsonbailey merged 8 commits intomainfrom
jb/aic-1935/tools-model-params-fallback
May 1, 2026
Merged

feat: fall back to model.parameters.tools when root tools absent#1330
jsonbailey merged 8 commits intomainfrom
jb/aic-1935/tools-model-params-fallback

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

@jsonbailey jsonbailey commented Apr 28, 2026

Summary

  • Adds _resolveTools() to LDAIConfigUtils — checks root-level tools first, falls back to model.parameters.tools for older AI configs
  • Root-level tools always takes priority when present
  • model.parameters.tools as an array or non-object is silently ignored (may be user-defined custom param)
  • Entries missing a name string are silently skipped; valid entries in the same map are still returned

Background

The LaunchDarkly AI Config API now sends tools in two places: updated configs send them at both root and model.parameters.tools; older configs only send them in model.parameters.tools. Previously the SDK only read root-level, leaving older configs with no tools.

Test plan

  • Existing tools tests pass
  • Tools parsed from model.parameters.tools when root key is absent
  • Root tools wins when both locations are present
  • model.parameters.tools as array → undefined
  • Entries missing name skipped; valid entries in same map returned

Jira: AIC-1935

🤖 Generated with Claude Code


Note

Medium Risk
Changes how tools are derived for agent/completion configs by adding a fallback to model.parameters.tools and new validation/logging, which could alter runtime tool availability for existing flags.

Overview
Adds a new tool-resolution path for AI configs: tools are now taken from the root-level tools map when present, otherwise parsed from model.parameters.tools to support older flag shapes.

Tool parsing now validates that tools are object maps (not arrays/invalid types), normalizes entries (including defaulting missing name to the map key), and emits warnings via an optionally passed logger. Tests were expanded to cover the fallback, precedence rules, and invalid-shape handling.

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

When root-level tools is absent, fall back to model.parameters.tools and
parse it as our LDTool map format. Arrays or entries missing a name field
are silently ignored.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

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

@github-actions
Copy link
Copy Markdown
Contributor

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

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

@jsonbailey jsonbailey changed the title feat(server-ai): fall back to model.parameters.tools when root tools absent feat: fall back to model.parameters.tools when root tools absent Apr 28, 2026
jsonbailey and others added 4 commits April 29, 2026 10:08
…s bad entries

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…root tools path, fall back to key name when name field absent

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey jsonbailey marked this pull request as ready for review April 30, 2026 14:43
@jsonbailey jsonbailey requested a review from a team as a code owner April 30, 2026 14:43
Comment thread packages/sdk/server-ai/src/api/config/LDAIConfigUtils.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 and found 1 potential issue.

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 76068a6. Configure here.

Comment thread packages/sdk/server-ai/src/api/config/LDAIConfigUtils.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@joker23 joker23 left a comment

Choose a reason for hiding this comment

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

1 nit comment

Comment thread packages/sdk/server-ai/src/api/config/LDAIConfigUtils.ts Outdated
Add type guards for the parameters and customParameters fields in
_parseToolsMap, consistent with existing guards on name, description,
and type. Blind casts are replaced with null/object/array checks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey jsonbailey changed the base branch from main to next-ai-release May 1, 2026 16:14
@jsonbailey jsonbailey changed the base branch from next-ai-release to main May 1, 2026 16:14
@jsonbailey jsonbailey merged commit 2c65c61 into main May 1, 2026
43 checks passed
@jsonbailey jsonbailey deleted the jb/aic-1935/tools-model-params-fallback branch May 1, 2026 17:11
@github-actions github-actions Bot mentioned this pull request May 1, 2026
jsonbailey pushed a commit that referenced this pull request May 1, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>server-sdk-ai: 0.19.0</summary>

##
[0.19.0](server-sdk-ai-v0.18.1...server-sdk-ai-v0.19.0)
(2026-05-01)


### Features

* Support fall back to model.parameters.tools when root tools absent
([#1330](#1330))
([2c65c61](2c65c61))
</details>

<details><summary>server-sdk-ai-langchain: 0.6.2</summary>

##
[0.6.2](server-sdk-ai-langchain-v0.6.1...server-sdk-ai-langchain-v0.6.2)
(2026-05-01)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.18.1 to ^0.19.0
  * peerDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.18.1 to ^0.19.0
</details>

<details><summary>server-sdk-ai-openai: 0.5.9</summary>

##
[0.5.9](server-sdk-ai-openai-v0.5.8...server-sdk-ai-openai-v0.5.9)
(2026-05-01)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.18.1 to ^0.19.0
  * peerDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.18.1 to ^0.19.0
</details>

<details><summary>server-sdk-ai-vercel: 0.5.9</summary>

##
[0.5.9](server-sdk-ai-vercel-v0.5.8...server-sdk-ai-vercel-v0.5.9)
(2026-05-01)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.18.1 to ^0.19.0
  * peerDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.18.1 to ^0.19.0
</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**
> Primarily a release/version-bump PR, but it publishes
`@launchdarkly/server-sdk-ai@0.19.0` which changes runtime behavior
around tool configuration fallback and could affect downstream
integrations.
> 
> **Overview**
> Updates the release manifest and bumps versions for
`@launchdarkly/server-sdk-ai` to `0.19.0` and its provider packages
(`server-sdk-ai-langchain` `0.6.2`, `server-sdk-ai-openai` `0.5.9`,
`server-sdk-ai-vercel` `0.5.9`).
> 
> Propagates the new `@launchdarkly/server-sdk-ai@0.19.0` dependency
range into provider `package.json` files and refreshes example app
dependencies to the new package versions, along with changelog entries
and the SDK version constant in `sdkInfo.ts`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ffc35f6. 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.

2 participants