Skip to content

Update dependency ai to v5#244675

Merged
Samiul-TheSoccerFan merged 20 commits intoelastic:mainfrom
Samiul-TheSoccerFan:update-ai-package
Dec 8, 2025
Merged

Update dependency ai to v5#244675
Samiul-TheSoccerFan merged 20 commits intoelastic:mainfrom
Samiul-TheSoccerFan:update-ai-package

Conversation

@Samiul-TheSoccerFan
Copy link
Contributor

@Samiul-TheSoccerFan Samiul-TheSoccerFan commented Nov 28, 2025

Summary

  • Update dependency ai to v5
  • Addressed the breaking changes
Screenshot 2025-11-28 at 2 38 46 PM

Security Checklist:

Purpose@ai-sdk/langchain provides the official adapter that converts LangChain's Runnable.stream() output into the AI SDK v5 UI message stream format. We use it in the search playground's conversational chain so the existing LangChain pipeline can feed the new createUIMessageStream/SSE infrastructure without rewriting the entire chain logic.

Justification – AI SDK v5 moved the LangChain adapter out of the core ai package; the only supported way to keep LangChain models streaming into UI chunks is this package. Using the upstream adapter keeps us aligned with Vercel's protocol changes (LC stream events, chunk metadata, etc.) and avoids maintaining fragile, duplicate conversion code in Kibana.

Alternatives explored –We looked at copying the old adapter logic, but the new UI chunk format (text, tools, reasoning, data events) changes quickly and is easy to get wrong. Reimplementing it ourselves would be brittle and hard to maintain, so we rely on the upstream package instead.

Existing dependencies – Kibana already depends on LangChain itself and on the base ai SDK, but neither now exposes a LangChain to UI stream bridge. @ai-sdk/langchain is the upstream successor to what used to be bundled in ai, so it’s effectively continuing the same capability with ongoing support, making it the preferred and only viable option.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

@Samiul-TheSoccerFan Samiul-TheSoccerFan added the release_note:skip Skip the PR/issue when compiling release notes label Nov 28, 2025
@Samiul-TheSoccerFan Samiul-TheSoccerFan requested a review from a team as a code owner November 28, 2025 19:38
@Samiul-TheSoccerFan Samiul-TheSoccerFan added backport:skip This PR does not require backporting Team:Search v9.3.0 labels Nov 28, 2025
@kibanamachine
Copy link
Contributor

Dependency Review Bot Analysis 🔍

Found 1 new third-party dependencies:

Package Version Vulnerabilities Health Score
@ai-sdk/langchain ^1.0.102 🔴 C: 0, 🟠 H: 0, 🟡 M: 0, 🟢 L: 0 @ai-sdk/langchain

Self Checklist

To help with the review, please update the PR description to address the following points for each new third-party dependency listed above:

  • Purpose: What is this dependency used for? Briefly explain its role in your changes.
  • Justification: Why is adding this dependency the best approach?
  • Alternatives explored: Were other options considered (e.g., using existing internal libraries/utilities, implementing the functionality directly)? If so, why was this dependency chosen over them?
  • Existing dependencies: Does Kibana have a dependency providing similar functionality? If so, why is the new one preferred?

Thank you for providing this information!

@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner November 28, 2025 19:59
@Samiul-TheSoccerFan Samiul-TheSoccerFan added the ci:project-deploy-elasticsearch Create an Elasticsearch Serverless project label Nov 28, 2025
@azasypkin
Copy link
Contributor

Thanks for the PR! I've updated labels to make sure we backport this particular upgrade to 8.19/9.1/9.2/9.3 branches where we still use the old version.

@azasypkin azasypkin added backport:all-open Backport to all branches that could still receive a release and removed backport:skip This PR does not require backporting labels Dec 1, 2025
@Samiul-TheSoccerFan
Copy link
Contributor Author

@elasticmachine merge upstream

@jeramysoucy
Copy link
Contributor

@Samiul-TheSoccerFan Could you complete the new dependency checklist?

I noticed that there is only a single reference to one function from the new dependency. I am interested in if any alternatives were considered, but also the overall justification. Thanks!

@jeramysoucy jeramysoucy self-requested a review December 1, 2025 19:51
@Samiul-TheSoccerFan
Copy link
Contributor Author

@jeramysoucy : I have updated the PR description with the security checklist and tried to provide an explanation with Alternative exploration.

Copy link
Contributor

@jeramysoucy jeramysoucy left a comment

Choose a reason for hiding this comment

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

Thanks!

@Samiul-TheSoccerFan
Copy link
Contributor Author

@elasticmachine merge upstream

@Samiul-TheSoccerFan
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

elasticmachine commented Dec 8, 2025

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
searchPlayground 237.0KB 236.6KB -454.0B

History

@Samiul-TheSoccerFan Samiul-TheSoccerFan merged commit 81c6347 into elastic:main Dec 8, 2025
13 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19, 9.1, 9.2

https://github.com/elastic/kibana/actions/runs/20036896296

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts
9.1 Backport failed because of merge conflicts
9.2 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 244675

Questions ?

Please refer to the Backport tool documentation

Samiul-TheSoccerFan added a commit to Samiul-TheSoccerFan/kibana that referenced this pull request Dec 8, 2025
## Summary

- Update dependency ai to v5
- Addressed the breaking changes

<img width="2552" height="1267" alt="Screenshot 2025-11-28 at 2 38
46 PM"
src="https://github.com/user-attachments/assets/44f9c824-79c5-4e7e-a0ad-216e79673f9e"
/>

### Security Checklist:
**Purpose** – `@ai-sdk/langchain` provides the official adapter that
converts LangChain's `Runnable.stream()` output into the AI SDK v5 `UI
message stream` format. We use it in the search playground's
conversational chain so the existing LangChain pipeline can feed the new
createUIMessageStream/SSE infrastructure without rewriting the entire
chain logic.

**Justification** – AI SDK v5 moved the LangChain adapter out of the
core `ai` package; the only supported way to keep LangChain models
streaming into UI chunks is this package. Using the upstream adapter
keeps us aligned with Vercel's protocol changes (LC stream events, chunk
metadata, etc.) and avoids maintaining fragile, duplicate conversion
code in Kibana.

**Alternatives explored** –We looked at copying the old adapter logic,
but the new UI chunk format (text, tools, reasoning, data events)
changes quickly and is easy to get wrong. Reimplementing it ourselves
would be brittle and hard to maintain, so we rely on the upstream
package instead.

**Existing dependencies** – Kibana already depends on LangChain itself
and on the base `ai` SDK, but neither now exposes a LangChain to UI
stream bridge. `@ai-sdk/langchain` is the upstream successor to what
used to be bundled in `ai`, so it’s effectively continuing the same
capability with ongoing support, making it the preferred and only viable
option.

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [X] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 81c6347)

# Conflicts:
#	.buildkite/scripts/steps/security/third_party_packages.txt
#	package.json
#	yarn.lock
@Samiul-TheSoccerFan
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
9.2
9.1
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

Samiul-TheSoccerFan added a commit to Samiul-TheSoccerFan/kibana that referenced this pull request Dec 8, 2025
## Summary

- Update dependency ai to v5
- Addressed the breaking changes

<img width="2552" height="1267" alt="Screenshot 2025-11-28 at 2 38
46 PM"
src="https://github.com/user-attachments/assets/44f9c824-79c5-4e7e-a0ad-216e79673f9e"
/>

### Security Checklist:
**Purpose** – `@ai-sdk/langchain` provides the official adapter that
converts LangChain's `Runnable.stream()` output into the AI SDK v5 `UI
message stream` format. We use it in the search playground's
conversational chain so the existing LangChain pipeline can feed the new
createUIMessageStream/SSE infrastructure without rewriting the entire
chain logic.

**Justification** – AI SDK v5 moved the LangChain adapter out of the
core `ai` package; the only supported way to keep LangChain models
streaming into UI chunks is this package. Using the upstream adapter
keeps us aligned with Vercel's protocol changes (LC stream events, chunk
metadata, etc.) and avoids maintaining fragile, duplicate conversion
code in Kibana.

**Alternatives explored** –We looked at copying the old adapter logic,
but the new UI chunk format (text, tools, reasoning, data events)
changes quickly and is easy to get wrong. Reimplementing it ourselves
would be brittle and hard to maintain, so we rely on the upstream
package instead.

**Existing dependencies** – Kibana already depends on LangChain itself
and on the base `ai` SDK, but neither now exposes a LangChain to UI
stream bridge. `@ai-sdk/langchain` is the upstream successor to what
used to be bundled in `ai`, so it’s effectively continuing the same
capability with ongoing support, making it the preferred and only viable
option.

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [X] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 81c6347)

# Conflicts:
#	.buildkite/scripts/steps/security/third_party_packages.txt
#	package.json
#	x-pack/solutions/search/plugins/search_playground/public/utils/stream.ts
#	x-pack/solutions/search/plugins/search_playground/server/lib/conversational_chain.ts
#	yarn.lock
mbondyra added a commit to mbondyra/kibana that referenced this pull request Dec 8, 2025
* commit '6647f813c9fa03ac0378e3d4756246e8dc4b4c76': (33 commits)
  [Detection Engine] Extracts Rules/Alerts/Exceptions permission to new Rules feature privileges (elastic#239634)
  [Agent Builder] Add Intro Tour (elastic#245551)
  Add datastream lifecycle support to indices metadata (elastic#245548)
  [Serverless] Update preconfigured connectors (elastic#245445)
  [Metrics][Discover] Discover to prefer line chars for time series data (elastic#244595)
  Update dependency @elastic/ebt to ^1.4.1 (main) (elastic#241629)
  [One Workflow] fix: request bodies with oneof schemas (`kibana.SetAlertsStatus`, etc) (elastic#245344)
  Update dependency ai to v5 (elastic#244675)
  Fix Discover trace waterfall behavior with duplicate spans (elastic#244984)
  [FSH] Migrated fs usage to kbn/fs for sample ingest (elastic#244163)
  Streamlang: Unskip type coercion test (elastic#245519)
  [Response Ops][Reporting] Fixing error in calculating delay value between retries (elastic#245431)
  Add TopNavMenuBeta to navigation plugin (elastic#243578)
  [scout] support custom servers configuration (elastic#244306)
  [Fleet] Run agentless background sync without dry run (elastic#245286)
  Fix Change Password Flaky Test (elastic#245443)
  Add new gap fill status for rules (elastic#242595)
  [Kibana Search] Move SLOs higher up in search results (elastic#245518)
  feat(slo): introduce find SLO instances internal route (elastic#245333)
  [FSH] Dropped unnecessary `fs` persistence for synthetics project code (elastic#244338)
  ...
Samiul-TheSoccerFan added a commit that referenced this pull request Dec 9, 2025
# Backport

This will backport the following commits from `main` to `8.19`:
- [Update dependency ai to v5
(#244675)](#244675)

<!--- Backport version: 10.2.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Samiul
Monir","email":"150824886+Samiul-TheSoccerFan@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-12-08T17:26:35Z","message":"Update
dependency ai to v5 (#244675)\n\n## Summary\n\n- Update dependency ai to
v5\n- Addressed the breaking changes\n\n<img width=\"2552\"
height=\"1267\" alt=\"Screenshot 2025-11-28 at 2
38\n46 PM\"\nsrc=\"https://github.com/user-attachments/assets/44f9c824-79c5-4e7e-a0ad-216e79673f9e\"\n/>\n\n###
Security Checklist:\n**Purpose** – `@ai-sdk/langchain` provides the
official adapter that\nconverts LangChain's `Runnable.stream()` output
into the AI SDK v5 `UI\nmessage stream` format. We use it in the search
playground's\nconversational chain so the existing LangChain pipeline
can feed the new\ncreateUIMessageStream/SSE infrastructure without
rewriting the entire\nchain logic.\n\n**Justification** – AI SDK v5
moved the LangChain adapter out of the\ncore `ai` package; the only
supported way to keep LangChain models\nstreaming into UI chunks is this
package. Using the upstream adapter\nkeeps us aligned with Vercel's
protocol changes (LC stream events, chunk\nmetadata, etc.) and avoids
maintaining fragile, duplicate conversion\ncode in
Kibana.\n\n**Alternatives explored** –We looked at copying the old
adapter logic,\nbut the new UI chunk format (text, tools, reasoning,
data events)\nchanges quickly and is easy to get wrong. Reimplementing
it ourselves\nwould be brittle and hard to maintain, so we rely on the
upstream\npackage instead.\n\n**Existing dependencies** – Kibana already
depends on LangChain itself\nand on the base `ai` SDK, but neither now
exposes a LangChain to UI\nstream bridge. `@ai-sdk/langchain` is the
upstream successor to what\nused to be bundled in `ai`, so it’s
effectively continuing the same\ncapability with ongoing support, making
it the preferred and only viable\noption.\n\n\n### Checklist\n\nCheck
the PR satisfies following conditions. \n\nReviewers should verify this
PR satisfies this list as well.\n\n- [X] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"81c634708ab1405b64a5ca524b0f62d84d351467","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Search","backport:all-open","ci:project-deploy-elasticsearch","v9.3.0"],"title":"Update
dependency ai to
v5","number":244675,"url":"https://github.com/elastic/kibana/pull/244675","mergeCommit":{"message":"Update
dependency ai to v5 (#244675)\n\n## Summary\n\n- Update dependency ai to
v5\n- Addressed the breaking changes\n\n<img width=\"2552\"
height=\"1267\" alt=\"Screenshot 2025-11-28 at 2
38\n46 PM\"\nsrc=\"https://github.com/user-attachments/assets/44f9c824-79c5-4e7e-a0ad-216e79673f9e\"\n/>\n\n###
Security Checklist:\n**Purpose** – `@ai-sdk/langchain` provides the
official adapter that\nconverts LangChain's `Runnable.stream()` output
into the AI SDK v5 `UI\nmessage stream` format. We use it in the search
playground's\nconversational chain so the existing LangChain pipeline
can feed the new\ncreateUIMessageStream/SSE infrastructure without
rewriting the entire\nchain logic.\n\n**Justification** – AI SDK v5
moved the LangChain adapter out of the\ncore `ai` package; the only
supported way to keep LangChain models\nstreaming into UI chunks is this
package. Using the upstream adapter\nkeeps us aligned with Vercel's
protocol changes (LC stream events, chunk\nmetadata, etc.) and avoids
maintaining fragile, duplicate conversion\ncode in
Kibana.\n\n**Alternatives explored** –We looked at copying the old
adapter logic,\nbut the new UI chunk format (text, tools, reasoning,
data events)\nchanges quickly and is easy to get wrong. Reimplementing
it ourselves\nwould be brittle and hard to maintain, so we rely on the
upstream\npackage instead.\n\n**Existing dependencies** – Kibana already
depends on LangChain itself\nand on the base `ai` SDK, but neither now
exposes a LangChain to UI\nstream bridge. `@ai-sdk/langchain` is the
upstream successor to what\nused to be bundled in `ai`, so it’s
effectively continuing the same\ncapability with ongoing support, making
it the preferred and only viable\noption.\n\n\n### Checklist\n\nCheck
the PR satisfies following conditions. \n\nReviewers should verify this
PR satisfies this list as well.\n\n- [X] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"81c634708ab1405b64a5ca524b0f62d84d351467"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/244675","number":244675,"mergeCommit":{"message":"Update
dependency ai to v5 (#244675)\n\n## Summary\n\n- Update dependency ai to
v5\n- Addressed the breaking changes\n\n<img width=\"2552\"
height=\"1267\" alt=\"Screenshot 2025-11-28 at 2
38\n46 PM\"\nsrc=\"https://github.com/user-attachments/assets/44f9c824-79c5-4e7e-a0ad-216e79673f9e\"\n/>\n\n###
Security Checklist:\n**Purpose** – `@ai-sdk/langchain` provides the
official adapter that\nconverts LangChain's `Runnable.stream()` output
into the AI SDK v5 `UI\nmessage stream` format. We use it in the search
playground's\nconversational chain so the existing LangChain pipeline
can feed the new\ncreateUIMessageStream/SSE infrastructure without
rewriting the entire\nchain logic.\n\n**Justification** – AI SDK v5
moved the LangChain adapter out of the\ncore `ai` package; the only
supported way to keep LangChain models\nstreaming into UI chunks is this
package. Using the upstream adapter\nkeeps us aligned with Vercel's
protocol changes (LC stream events, chunk\nmetadata, etc.) and avoids
maintaining fragile, duplicate conversion\ncode in
Kibana.\n\n**Alternatives explored** –We looked at copying the old
adapter logic,\nbut the new UI chunk format (text, tools, reasoning,
data events)\nchanges quickly and is easy to get wrong. Reimplementing
it ourselves\nwould be brittle and hard to maintain, so we rely on the
upstream\npackage instead.\n\n**Existing dependencies** – Kibana already
depends on LangChain itself\nand on the base `ai` SDK, but neither now
exposes a LangChain to UI\nstream bridge. `@ai-sdk/langchain` is the
upstream successor to what\nused to be bundled in `ai`, so it’s
effectively continuing the same\ncapability with ongoing support, making
it the preferred and only viable\noption.\n\n\n### Checklist\n\nCheck
the PR satisfies following conditions. \n\nReviewers should verify this
PR satisfies this list as well.\n\n- [X] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"81c634708ab1405b64a5ca524b0f62d84d351467"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Samiul-TheSoccerFan added a commit that referenced this pull request Dec 9, 2025
# Backport

This will backport the following commits from `main` to `9.1`:
- [Update dependency ai to v5
(#244675)](#244675)

<!--- Backport version: 10.2.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Samiul
Monir","email":"150824886+Samiul-TheSoccerFan@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-12-08T17:26:35Z","message":"Update
dependency ai to v5 (#244675)\n\n## Summary\n\n- Update dependency ai to
v5\n- Addressed the breaking changes\n\n<img width=\"2552\"
height=\"1267\" alt=\"Screenshot 2025-11-28 at 2
38\n46 PM\"\nsrc=\"https://github.com/user-attachments/assets/44f9c824-79c5-4e7e-a0ad-216e79673f9e\"\n/>\n\n###
Security Checklist:\n**Purpose** – `@ai-sdk/langchain` provides the
official adapter that\nconverts LangChain's `Runnable.stream()` output
into the AI SDK v5 `UI\nmessage stream` format. We use it in the search
playground's\nconversational chain so the existing LangChain pipeline
can feed the new\ncreateUIMessageStream/SSE infrastructure without
rewriting the entire\nchain logic.\n\n**Justification** – AI SDK v5
moved the LangChain adapter out of the\ncore `ai` package; the only
supported way to keep LangChain models\nstreaming into UI chunks is this
package. Using the upstream adapter\nkeeps us aligned with Vercel's
protocol changes (LC stream events, chunk\nmetadata, etc.) and avoids
maintaining fragile, duplicate conversion\ncode in
Kibana.\n\n**Alternatives explored** –We looked at copying the old
adapter logic,\nbut the new UI chunk format (text, tools, reasoning,
data events)\nchanges quickly and is easy to get wrong. Reimplementing
it ourselves\nwould be brittle and hard to maintain, so we rely on the
upstream\npackage instead.\n\n**Existing dependencies** – Kibana already
depends on LangChain itself\nand on the base `ai` SDK, but neither now
exposes a LangChain to UI\nstream bridge. `@ai-sdk/langchain` is the
upstream successor to what\nused to be bundled in `ai`, so it’s
effectively continuing the same\ncapability with ongoing support, making
it the preferred and only viable\noption.\n\n\n### Checklist\n\nCheck
the PR satisfies following conditions. \n\nReviewers should verify this
PR satisfies this list as well.\n\n- [X] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"81c634708ab1405b64a5ca524b0f62d84d351467","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Search","backport:all-open","ci:project-deploy-elasticsearch","v9.3.0"],"title":"Update
dependency ai to
v5","number":244675,"url":"https://github.com/elastic/kibana/pull/244675","mergeCommit":{"message":"Update
dependency ai to v5 (#244675)\n\n## Summary\n\n- Update dependency ai to
v5\n- Addressed the breaking changes\n\n<img width=\"2552\"
height=\"1267\" alt=\"Screenshot 2025-11-28 at 2
38\n46 PM\"\nsrc=\"https://github.com/user-attachments/assets/44f9c824-79c5-4e7e-a0ad-216e79673f9e\"\n/>\n\n###
Security Checklist:\n**Purpose** – `@ai-sdk/langchain` provides the
official adapter that\nconverts LangChain's `Runnable.stream()` output
into the AI SDK v5 `UI\nmessage stream` format. We use it in the search
playground's\nconversational chain so the existing LangChain pipeline
can feed the new\ncreateUIMessageStream/SSE infrastructure without
rewriting the entire\nchain logic.\n\n**Justification** – AI SDK v5
moved the LangChain adapter out of the\ncore `ai` package; the only
supported way to keep LangChain models\nstreaming into UI chunks is this
package. Using the upstream adapter\nkeeps us aligned with Vercel's
protocol changes (LC stream events, chunk\nmetadata, etc.) and avoids
maintaining fragile, duplicate conversion\ncode in
Kibana.\n\n**Alternatives explored** –We looked at copying the old
adapter logic,\nbut the new UI chunk format (text, tools, reasoning,
data events)\nchanges quickly and is easy to get wrong. Reimplementing
it ourselves\nwould be brittle and hard to maintain, so we rely on the
upstream\npackage instead.\n\n**Existing dependencies** – Kibana already
depends on LangChain itself\nand on the base `ai` SDK, but neither now
exposes a LangChain to UI\nstream bridge. `@ai-sdk/langchain` is the
upstream successor to what\nused to be bundled in `ai`, so it’s
effectively continuing the same\ncapability with ongoing support, making
it the preferred and only viable\noption.\n\n\n### Checklist\n\nCheck
the PR satisfies following conditions. \n\nReviewers should verify this
PR satisfies this list as well.\n\n- [X] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"81c634708ab1405b64a5ca524b0f62d84d351467"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/244675","number":244675,"mergeCommit":{"message":"Update
dependency ai to v5 (#244675)\n\n## Summary\n\n- Update dependency ai to
v5\n- Addressed the breaking changes\n\n<img width=\"2552\"
height=\"1267\" alt=\"Screenshot 2025-11-28 at 2
38\n46 PM\"\nsrc=\"https://github.com/user-attachments/assets/44f9c824-79c5-4e7e-a0ad-216e79673f9e\"\n/>\n\n###
Security Checklist:\n**Purpose** – `@ai-sdk/langchain` provides the
official adapter that\nconverts LangChain's `Runnable.stream()` output
into the AI SDK v5 `UI\nmessage stream` format. We use it in the search
playground's\nconversational chain so the existing LangChain pipeline
can feed the new\ncreateUIMessageStream/SSE infrastructure without
rewriting the entire\nchain logic.\n\n**Justification** – AI SDK v5
moved the LangChain adapter out of the\ncore `ai` package; the only
supported way to keep LangChain models\nstreaming into UI chunks is this
package. Using the upstream adapter\nkeeps us aligned with Vercel's
protocol changes (LC stream events, chunk\nmetadata, etc.) and avoids
maintaining fragile, duplicate conversion\ncode in
Kibana.\n\n**Alternatives explored** –We looked at copying the old
adapter logic,\nbut the new UI chunk format (text, tools, reasoning,
data events)\nchanges quickly and is easy to get wrong. Reimplementing
it ourselves\nwould be brittle and hard to maintain, so we rely on the
upstream\npackage instead.\n\n**Existing dependencies** – Kibana already
depends on LangChain itself\nand on the base `ai` SDK, but neither now
exposes a LangChain to UI\nstream bridge. `@ai-sdk/langchain` is the
upstream successor to what\nused to be bundled in `ai`, so it’s
effectively continuing the same\ncapability with ongoing support, making
it the preferred and only viable\noption.\n\n\n### Checklist\n\nCheck
the PR satisfies following conditions. \n\nReviewers should verify this
PR satisfies this list as well.\n\n- [X] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"81c634708ab1405b64a5ca524b0f62d84d351467"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Samiul-TheSoccerFan added a commit that referenced this pull request Dec 9, 2025
# Backport

This will backport the following commits from `main` to `9.2`:
- [Update dependency ai to v5
(#244675)](#244675)

<!--- Backport version: 10.2.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Samiul
Monir","email":"150824886+Samiul-TheSoccerFan@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-12-08T17:26:35Z","message":"Update
dependency ai to v5 (#244675)\n\n## Summary\n\n- Update dependency ai to
v5\n- Addressed the breaking changes\n\n<img width=\"2552\"
height=\"1267\" alt=\"Screenshot 2025-11-28 at 2
38\n46 PM\"\nsrc=\"https://github.com/user-attachments/assets/44f9c824-79c5-4e7e-a0ad-216e79673f9e\"\n/>\n\n###
Security Checklist:\n**Purpose** – `@ai-sdk/langchain` provides the
official adapter that\nconverts LangChain's `Runnable.stream()` output
into the AI SDK v5 `UI\nmessage stream` format. We use it in the search
playground's\nconversational chain so the existing LangChain pipeline
can feed the new\ncreateUIMessageStream/SSE infrastructure without
rewriting the entire\nchain logic.\n\n**Justification** – AI SDK v5
moved the LangChain adapter out of the\ncore `ai` package; the only
supported way to keep LangChain models\nstreaming into UI chunks is this
package. Using the upstream adapter\nkeeps us aligned with Vercel's
protocol changes (LC stream events, chunk\nmetadata, etc.) and avoids
maintaining fragile, duplicate conversion\ncode in
Kibana.\n\n**Alternatives explored** –We looked at copying the old
adapter logic,\nbut the new UI chunk format (text, tools, reasoning,
data events)\nchanges quickly and is easy to get wrong. Reimplementing
it ourselves\nwould be brittle and hard to maintain, so we rely on the
upstream\npackage instead.\n\n**Existing dependencies** – Kibana already
depends on LangChain itself\nand on the base `ai` SDK, but neither now
exposes a LangChain to UI\nstream bridge. `@ai-sdk/langchain` is the
upstream successor to what\nused to be bundled in `ai`, so it’s
effectively continuing the same\ncapability with ongoing support, making
it the preferred and only viable\noption.\n\n\n### Checklist\n\nCheck
the PR satisfies following conditions. \n\nReviewers should verify this
PR satisfies this list as well.\n\n- [X] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"81c634708ab1405b64a5ca524b0f62d84d351467","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Search","backport:all-open","ci:project-deploy-elasticsearch","v9.3.0"],"title":"Update
dependency ai to
v5","number":244675,"url":"https://github.com/elastic/kibana/pull/244675","mergeCommit":{"message":"Update
dependency ai to v5 (#244675)\n\n## Summary\n\n- Update dependency ai to
v5\n- Addressed the breaking changes\n\n<img width=\"2552\"
height=\"1267\" alt=\"Screenshot 2025-11-28 at 2
38\n46 PM\"\nsrc=\"https://github.com/user-attachments/assets/44f9c824-79c5-4e7e-a0ad-216e79673f9e\"\n/>\n\n###
Security Checklist:\n**Purpose** – `@ai-sdk/langchain` provides the
official adapter that\nconverts LangChain's `Runnable.stream()` output
into the AI SDK v5 `UI\nmessage stream` format. We use it in the search
playground's\nconversational chain so the existing LangChain pipeline
can feed the new\ncreateUIMessageStream/SSE infrastructure without
rewriting the entire\nchain logic.\n\n**Justification** – AI SDK v5
moved the LangChain adapter out of the\ncore `ai` package; the only
supported way to keep LangChain models\nstreaming into UI chunks is this
package. Using the upstream adapter\nkeeps us aligned with Vercel's
protocol changes (LC stream events, chunk\nmetadata, etc.) and avoids
maintaining fragile, duplicate conversion\ncode in
Kibana.\n\n**Alternatives explored** –We looked at copying the old
adapter logic,\nbut the new UI chunk format (text, tools, reasoning,
data events)\nchanges quickly and is easy to get wrong. Reimplementing
it ourselves\nwould be brittle and hard to maintain, so we rely on the
upstream\npackage instead.\n\n**Existing dependencies** – Kibana already
depends on LangChain itself\nand on the base `ai` SDK, but neither now
exposes a LangChain to UI\nstream bridge. `@ai-sdk/langchain` is the
upstream successor to what\nused to be bundled in `ai`, so it’s
effectively continuing the same\ncapability with ongoing support, making
it the preferred and only viable\noption.\n\n\n### Checklist\n\nCheck
the PR satisfies following conditions. \n\nReviewers should verify this
PR satisfies this list as well.\n\n- [X] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"81c634708ab1405b64a5ca524b0f62d84d351467"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/244675","number":244675,"mergeCommit":{"message":"Update
dependency ai to v5 (#244675)\n\n## Summary\n\n- Update dependency ai to
v5\n- Addressed the breaking changes\n\n<img width=\"2552\"
height=\"1267\" alt=\"Screenshot 2025-11-28 at 2
38\n46 PM\"\nsrc=\"https://github.com/user-attachments/assets/44f9c824-79c5-4e7e-a0ad-216e79673f9e\"\n/>\n\n###
Security Checklist:\n**Purpose** – `@ai-sdk/langchain` provides the
official adapter that\nconverts LangChain's `Runnable.stream()` output
into the AI SDK v5 `UI\nmessage stream` format. We use it in the search
playground's\nconversational chain so the existing LangChain pipeline
can feed the new\ncreateUIMessageStream/SSE infrastructure without
rewriting the entire\nchain logic.\n\n**Justification** – AI SDK v5
moved the LangChain adapter out of the\ncore `ai` package; the only
supported way to keep LangChain models\nstreaming into UI chunks is this
package. Using the upstream adapter\nkeeps us aligned with Vercel's
protocol changes (LC stream events, chunk\nmetadata, etc.) and avoids
maintaining fragile, duplicate conversion\ncode in
Kibana.\n\n**Alternatives explored** –We looked at copying the old
adapter logic,\nbut the new UI chunk format (text, tools, reasoning,
data events)\nchanges quickly and is easy to get wrong. Reimplementing
it ourselves\nwould be brittle and hard to maintain, so we rely on the
upstream\npackage instead.\n\n**Existing dependencies** – Kibana already
depends on LangChain itself\nand on the base `ai` SDK, but neither now
exposes a LangChain to UI\nstream bridge. `@ai-sdk/langchain` is the
upstream successor to what\nused to be bundled in `ai`, so it’s
effectively continuing the same\ncapability with ongoing support, making
it the preferred and only viable\noption.\n\n\n### Checklist\n\nCheck
the PR satisfies following conditions. \n\nReviewers should verify this
PR satisfies this list as well.\n\n- [X] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"81c634708ab1405b64a5ca524b0f62d84d351467"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:all-open Backport to all branches that could still receive a release ci:project-deploy-elasticsearch Create an Elasticsearch Serverless project release_note:skip Skip the PR/issue when compiling release notes Team:Search v8.19.9 v9.1.9 v9.2.3 v9.3.0

6 participants