feat: replace LangChainProvider with Runner protocol implementation (AIC-2388)#1338
Merged
jsonbailey merged 13 commits intonext-ai-releasefrom May 6, 2026
Merged
Conversation
07f1af2 to
66bb862
Compare
7a6a7b8 to
58f8249
Compare
66bb862 to
c9d433a
Compare
58f8249 to
fa4a5cf
Compare
c9d433a to
42f17c6
Compare
fa4a5cf to
1b5dcc1
Compare
42f17c6 to
6902ffa
Compare
1b5dcc1 to
175c210
Compare
joker23
previously approved these changes
May 5, 2026
joker23
reviewed
May 5, 2026
joker23
previously approved these changes
May 5, 2026
Adds LangChainModelRunner, LangChainAgentRunner, and LangChainRunnerFactory that implement the Runner protocol introduced in JS PR 6. The runners take an LDAICompletionConfig / LDAIAgentConfig at construction and expose run(prompt: string) returning RunnerResult. LangChainModelRunner.run(prompt) prepends the config's messages before the user prompt. LangChainAgentRunner uses LangChain's native bindTools to run a tool-calling loop, populating LDAIMetrics.toolCalls with the names of tools the model invoked. Tool implementations are supplied via a ToolRegistry passed to LangChainRunnerFactory.createAgent. mapProvider is renamed to mapProviderName on both the helper module and the LangChainProvider class; the old mapProvider name is kept as a deprecated alias. The deprecated LangChainProvider class is preserved so AIProviderFactory continues to work during the migration. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ent on construction 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>
Previously the tool-calling loop fell off the end silently and returned success=true. Now only the clean-exit path (no more tool calls) sets success=true; hitting the iteration cap returns success=false with a logger warning. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
JSON.stringify(undefined) returns undefined (not a string), producing a malformed ToolMessage content. Nullish-coalesce to empty string so the message content is always a valid string. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2479fb2 to
d297039
Compare
joker23
approved these changes
May 6, 2026
jsonbailey
added a commit
that referenced
this pull request
May 6, 2026
This was referenced May 6, 2026
jsonbailey
added a commit
that referenced
this pull request
May 7, 2026
… (AIC-2388) Now that all provider packages (#1337 OpenAI, #1338 LangChain, #1339 Vercel) have migrated to the Runner protocol, the deprecated compatibility surface on the umbrella `feat/next-ai-release` branch can be removed. BREAKING CHANGE: Removes the following deprecated APIs: AIProvider abstract base class: - `invokeModel()` and `invokeStructuredModel()` instance methods - `static create()` factory method - `protected logger` field on the constructor (provider subclasses now declare their own private `_logger` field) LDAIClient deprecated method aliases: - `config()` (use `completionConfig`) - `agent()` (use `agentConfig`) - `agents()` (use `agentConfigs`) - `createChat()` and `initChat()` (use `createModel`) Public types: - `StructuredResponse` (only consumed by the removed `invokeStructuredModel` method) Type narrowing on `AIProvider` and `RunnerFactory`: - `createModel(config: LDAICompletionConfig | LDAIJudgeConfig)` - `createAgent(config: LDAIAgentConfig)` - `createAgentGraph(graphDef: AgentGraphDefinition)` Previously these accepted the wider `LDAIConfigKind` union; the new signatures mirror what the provider subclasses already declared and surface mode mismatches at the type level. Also updates README examples to use `createModel`/`run()` and removes the stale `_LegacyProviderAdapter` references in `RunnerFactory` doc comments. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jsonbailey
added a commit
that referenced
this pull request
May 7, 2026
Merged
jsonbailey
pushed a commit
that referenced
this pull request
May 7, 2026
🤖 I have created a release *beep* *boop* --- <details><summary>server-sdk-ai: 0.20.0</summary> ## [0.20.0](server-sdk-ai-v0.19.1...server-sdk-ai-v0.20.0) (2026-05-07) ### ⚠ BREAKING CHANGES * Rename LDAIMetrics.usage and LDAIGraphMetrics.usage to .tokens ([#1366](#1366)) * Remove AIProvider deprecated methods and create*/init* aliases (AIC-2388) ([#1363](#1363)) * Build judge input as string and strip legacy judge config messages ([#1364](#1364)) * Use LDAIGraphMetricSummary for graph metric summary ([#1362](#1362)) ### Features * add Evaluator class for judge orchestration ([#1331](#1331)) ([54faa69](54faa69)) * add ManagedAgent with evaluations support ([#1334](#1334)) ([7f09c46](7f09c46)) * add ManagedGraphResult, GraphMetricSummary, and ManagedAgentGraph ([#1335](#1335)) ([09fa1db](09fa1db)) * introduce ManagedResult, RunnerResult, and LDAIMetricSummary ([#1332](#1332)) ([5040122](5040122)) * Remove AIProvider deprecated methods and create*/init* aliases (AIC-2388) ([#1363](#1363)) ([ad66314](ad66314)) * Rename LDAIMetrics.usage and LDAIGraphMetrics.usage to .tokens ([#1366](#1366)) ([ff932b7](ff932b7)) * Replace OpenAIProvider with Runner protocol implementation (AIC-2388) ([#1337](#1337)) ([e32a955](e32a955)) ### Bug Fixes * Build judge input as string and strip legacy judge config messages ([#1364](#1364)) ([c90034b](c90034b)) * Use LDAIGraphMetricSummary for graph metric summary ([#1362](#1362)) ([76a4bf2](76a4bf2)) </details> <details><summary>server-sdk-ai-langchain: 0.7.0</summary> ## [0.7.0](server-sdk-ai-langchain-v0.6.3...server-sdk-ai-langchain-v0.7.0) (2026-05-07) ### ⚠ BREAKING CHANGES * Rename LDAIMetrics.usage and LDAIGraphMetrics.usage to .tokens ([#1366](#1366)) * Remove AIProvider deprecated methods and create*/init* aliases (AIC-2388) ([#1363](#1363)) * Build judge input as string and strip legacy judge config messages ([#1364](#1364)) ### Features * Remove AIProvider deprecated methods and create*/init* aliases (AIC-2388) ([#1363](#1363)) ([ad66314](ad66314)) * Rename LDAIMetrics.usage and LDAIGraphMetrics.usage to .tokens ([#1366](#1366)) ([ff932b7](ff932b7)) * Replace LangChainProvider with Runner protocol implementation (AIC-2388) ([#1338](#1338)) ([113a0d2](113a0d2)) ### Bug Fixes * Build judge input as string and strip legacy judge config messages ([#1364](#1364)) ([c90034b](c90034b)) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^0.19.1 to ^0.20.0 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^0.19.1 to ^0.20.0 </details> <details><summary>server-sdk-ai-openai: 0.6.0</summary> ## [0.6.0](server-sdk-ai-openai-v0.5.10...server-sdk-ai-openai-v0.6.0) (2026-05-07) ### ⚠ BREAKING CHANGES * Rename LDAIMetrics.usage and LDAIGraphMetrics.usage to .tokens ([#1366](#1366)) * Remove AIProvider deprecated methods and create*/init* aliases (AIC-2388) ([#1363](#1363)) * Build judge input as string and strip legacy judge config messages ([#1364](#1364)) ### Features * Remove AIProvider deprecated methods and create*/init* aliases (AIC-2388) ([#1363](#1363)) ([ad66314](ad66314)) * Rename LDAIMetrics.usage and LDAIGraphMetrics.usage to .tokens ([#1366](#1366)) ([ff932b7](ff932b7)) * Replace OpenAIProvider with Runner protocol implementation (AIC-2388) ([#1337](#1337)) ([e32a955](e32a955)) ### Bug Fixes * Build judge input as string and strip legacy judge config messages ([#1364](#1364)) ([c90034b](c90034b)) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^0.19.1 to ^0.20.0 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^0.19.1 to ^0.20.0 </details> <details><summary>server-sdk-ai-vercel: 0.6.0</summary> ## [0.6.0](server-sdk-ai-vercel-v0.5.10...server-sdk-ai-vercel-v0.6.0) (2026-05-07) ### ⚠ BREAKING CHANGES * Rename LDAIMetrics.usage and LDAIGraphMetrics.usage to .tokens ([#1366](#1366)) * Remove AIProvider deprecated methods and create*/init* aliases (AIC-2388) ([#1363](#1363)) * Build judge input as string and strip legacy judge config messages ([#1364](#1364)) ### Features * Remove AIProvider deprecated methods and create*/init* aliases (AIC-2388) ([#1363](#1363)) ([ad66314](ad66314)) * Rename LDAIMetrics.usage and LDAIGraphMetrics.usage to .tokens ([#1366](#1366)) ([ff932b7](ff932b7)) * replace VercelProvider with Runner protocol implementation (AIC-2388) ([#1339](#1339)) ([d5a62de](d5a62de)) ### Bug Fixes * add zod devDependency to Vercel provider (peer dep of ai v5) ([aab6226](aab6226)) * Build judge input as string and strip legacy judge config messages ([#1364](#1364)) ([c90034b](c90034b)) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/server-sdk-ai bumped from ^0.19.1 to ^0.20.0 * peerDependencies * @launchdarkly/server-sdk-ai bumped from ^0.19.1 to ^0.20.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** > This is primarily a versioning/release metadata update, but it ships breaking API changes in `@launchdarkly/server-sdk-ai` and provider packages that may require consumer code updates (e.g., metrics field rename and deprecated method removals). > > **Overview** > Publishes a new release for `@launchdarkly/server-sdk-ai` (`0.19.1` → `0.20.0`) and the provider packages (`server-sdk-ai-langchain` `0.6.3` → `0.7.0`, `server-sdk-ai-openai`/`server-sdk-ai-vercel` `0.5.10` → `0.6.0`), updating `.release-please-manifest.json`, package versions, and `sdkInfo.ts`. > > Updates provider `peerDependencies`/`devDependencies` to require `@launchdarkly/server-sdk-ai@^0.20.0`, and bumps all `server-ai` examples to depend on the new SDK/provider versions. Changelogs highlight *breaking changes* including renaming metrics `usage` → `tokens`, removing deprecated `AIProvider` methods/aliases, and judge-input/config cleanup (plus additional `server-sdk-ai` graph/managed result summary changes). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit cb3aebc. 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the legacy
LangChainProviderextension model with the Runner protocol for the LangChain provider package. This is a breaking change —LangChainProvideris removed.Removed:
LangChainProviderclass and its tests — callers must migrate to the new factory/runner patternAdded:
LangChainModelRunner—Runnerfor chat completions;run(input: string | LDMessage[], outputType?)returnsRunnerResult { content, metrics, raw, parsed? }. Structured output is parsed viawithStructuredOutput.LangChainAgentRunner—Runnerfor a single agent. Runs a tool-calling loop using LangChain's nativebindToolsandToolMessage. Tool definitions come fromconfig.model.parameters.tools; tool callables come from a caller-suppliedToolRegistry. PopulatesLDAIMetrics.toolCallswith the names of tools invoked.LangChainRunnerFactory— extendsAIProvider; exposescreateModel(config)andcreateAgent(config, tools?). Applies OpenTelemetry instrumentation (via@traceloop/instrumentation-langchain) fire-and-forget in the constructor if available.Renamed / moved:
langchainHelper.ts→LangChainHelper.ts(casing fix)createLangChainModelmoved fromLangChainRunnerFactoryintoLangChainHelperand exported from the packageRenamed:
mapProvider→mapProviderNamein helper exportsTest plan
yarn workspace @launchdarkly/server-sdk-ai-langchain test— all tests passyarn workspace @launchdarkly/server-sdk-ai-langchain lint— cleanyarn workspace @launchdarkly/server-sdk-ai-langchain run build— clean🤖 Generated with Claude Code
Note
High Risk
High risk because this is a breaking API change that removes
LangChainProviderin favor of new runner/factory entrypoints, requiring downstream code migration. It also changes how tools, metrics (usage/toolCalls), and structured output are produced/returned.Overview
Breaking change: removes the
LangChainProviderclass (and its tests) and replaces it with a Runner-protocol integration.Adds
LangChainRunnerFactoryto create either aLangChainModelRunner(chat completions) orLangChainAgentRunner(agent execution viacreateAgent), including optional OpenTelemetry ESM instrumentation. IntroducesLangChainHelperutilities for provider mapping, message conversion, tool wrapping (buildStructuredTools), tool-call extraction, and token-usage aggregation, and updates package exports to expose the new factory/runners/helpers.Reviewed by Cursor Bugbot for commit 3b1aa33. Bugbot is set up for automated code reviews on this repo. Configure here.