Skip to content

feat: Bump to LangChain 1.0 and drop community package requirement#1311

Merged
jsonbailey merged 8 commits into
launchdarkly:mainfrom
epietrowicz:bugfix/fix-deps-error
Apr 27, 2026
Merged

feat: Bump to LangChain 1.0 and drop community package requirement#1311
jsonbailey merged 8 commits into
launchdarkly:mainfrom
epietrowicz:bugfix/fix-deps-error

Conversation

@epietrowicz

@epietrowicz epietrowicz commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

This change bumps @langchain/community to the current npm release line and aligns @langchain/core, langchain, and @traceloop/instrumentation-langchain so peer dependencies resolve cleanly. It also adjusts token usage typing for LangChain 1.x response metadata.

Made with Cursor


Note

Medium Risk
Dependency upgrades to LangChain v1 and instrumentation packages may introduce runtime/typing incompatibilities for consumers. Metrics extraction now relies on usage_metadata, so token counts could change or be missing depending on provider support.

Overview
Upgrades @launchdarkly/server-sdk-ai-langchain to LangChain v1 by bumping langchain, @langchain/core, and @traceloop/instrumentation-langchain, and drops @langchain/community as a direct/peer dependency.

Updates LangChainProvider.getAIMetricsFromResponse (and its tests) to read token usage from LangChain v1’s AIMessage.usage_metadata (*_tokens fields) instead of the older response_metadata.tokenUsage shape.

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

@langchain/community was added speculatively during the ESM migration
but has never been imported by any source or test file. Removing it
eliminates the entire transitive stagehand -> dotenv@^16 conflict chain
at the root, rather than hoping an upstream fix arrives.

Also restricts @langchain/core, langchain, and
@traceloop/instrumentation-langchain peer deps to 1.x-only, dropping
support for the 0.2/0.3 range that triggered the original issue.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey

Copy link
Copy Markdown
Contributor

Thanks for digging into this and opening the PR! The root cause you identified is real — the transitive @langchain/community@browserbasehq/stagehanddotenv@^16.4.5 chain does cause the ERESOLVE conflict. After reviewing this more deeply we made a couple of adjustments and pushed them onto your branch.

What we changed and why:

  1. Removed @langchain/community entirely (from both devDependencies and peerDependencies).

    We traced back through the git history and found that @langchain/community was added speculatively during an ESM migration refactor — no source or test file actually imports it. Our provider only uses @langchain/core (for BaseChatModel and message types) and langchain (for initChatModel). While initChatModel can dynamically load community-based providers at runtime, that's the user's responsibility — they'll install whichever provider package they need. Keeping @langchain/community as a peer dep imposed its entire transitive dependency tree (including stagehand) on every user, even those who never touch a community model.

    Dropping it is the correct fix here — bumping to 1.x alone wouldn't have resolved the conflict anyway, since @langchain/community@1.x still pins @browserbasehq/stagehand@^1.0.0, and every stagehand 1.x release requires dotenv@^16.4.5.

  2. Restricted all remaining langchain peer deps to 1.x only (@langchain/core, langchain, @traceloop/instrumentation-langchain).

    Your instinct to bump to 1.x was right. We went a step further and dropped the ^0.2.0 || ^0.3.0 fallback ranges entirely — there's no benefit to maintaining compatibility with pre-1.0 versions going forward.

  3. Kept your LangChainProvider.ts type cast for tokenUsage — that's a valid fix for 1.x's stricter response_metadata typing.

Thanks again for the contribution!

@jsonbailey jsonbailey marked this pull request as ready for review April 27, 2026 17:07
@jsonbailey jsonbailey requested a review from a team as a code owner April 27, 2026 17:07
@jsonbailey jsonbailey changed the title fix: align LangChain deps with @langchain/community 1.x feat: Bump to LangChain 1.0 and drop community package requirement Apr 27, 2026

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

Fix All in Cursor

Reviewed by Cursor Bugbot for commit a849c6f. Configure here.

Comment thread packages/ai-providers/server-ai-langchain/src/LangChainProvider.ts Outdated
jsonbailey and others added 4 commits April 27, 2026 13:07
response_metadata.tokenUsage is an OpenAI-specific legacy path.
LangChain standardized token counts onto usage_metadata (input_tokens,
output_tokens, total_tokens) as a first-class field on AIMessage.

Primary path is now usage_metadata; falls back to response_metadata.tokenUsage
for any providers that have not yet migrated to the standard field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
LangChain 1.x core populates response_metadata.tokenUsage FROM
usage_metadata, not the other way around. Any 1.x-compatible provider
will set usage_metadata, making the fallback unreachable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey jsonbailey merged commit f5a1c29 into launchdarkly:main Apr 27, 2026
35 of 54 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 27, 2026
joker23 pushed a commit that referenced this pull request Apr 27, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>jest: 1.0.13</summary>

##
[1.0.13](jest-v1.0.12...jest-v1.0.13)
(2026-04-27)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/react-native-client-sdk bumped from ~10.17.1 to ~10.17.2
</details>

<details><summary>react-native-client-sdk: 10.17.2</summary>

##
[10.17.2](react-native-client-sdk-v10.17.1...react-native-client-sdk-v10.17.2)
(2026-04-27)


### Bug Fixes

* **react-native:** `package.json` should declare esm format
([#1322](#1322))
([149ae73](149ae73))
</details>

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

##
[0.18.0](server-sdk-ai-v0.17.1...server-sdk-ai-v0.18.0)
(2026-04-27)


### Features

* Add root-level tools map with customParameters to AI Config types
([#1295](#1295))
([487182b](487182b))
</details>

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

##
[0.6.0](server-sdk-ai-langchain-v0.5.6...server-sdk-ai-langchain-v0.6.0)
(2026-04-27)


### Features

* Bump to LangChain 1.0 and drop community package requirement
([#1311](#1311))
([f5a1c29](f5a1c29))


### Dependencies

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

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

##
[0.5.7](server-sdk-ai-openai-v0.5.6...server-sdk-ai-openai-v0.5.7)
(2026-04-27)


### Dependencies

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

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

##
[0.5.7](server-sdk-ai-vercel-v0.5.6...server-sdk-ai-vercel-v0.5.7)
(2026-04-27)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.17.1 to ^0.18.0
  * peerDependencies
    * @launchdarkly/server-sdk-ai bumped from ^0.17.0 to ^0.18.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 updates AI provider
peer/dependency ranges (notably moving `server-sdk-ai-langchain` to
LangChain v1) which may introduce runtime or type-compatibility issues
for consumers.
> 
> **Overview**
> Updates release metadata and publishes new versions of several
packages (`server-sdk-ai` `0.18.0`, `server-sdk-ai-langchain` `0.6.0`,
`server-sdk-ai-openai`/`server-sdk-ai-vercel` `0.5.7`,
`react-native-client-sdk` `10.17.2`, and `@launchdarkly/jest` `1.0.13`).
> 
> This release bumps the AI LangChain provider to *LangChain 1.x* and
aligns AI provider packages’ `@launchdarkly/server-sdk-ai` peer/dev
dependency requirements to `^0.18.0`; examples are updated to consume
the new versions. It also includes a React Native SDK packaging fix
(declaring ESM) and propagates that version bump into the React Native
examples and Jest tooling dependency.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
530460b. 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.

3 participants