feat: add LangChain Runner protocol implementation (AIC-2388)#1338
Draft
jsonbailey wants to merge 1 commit intojb/aic-2388/js-openai-runnerfrom
Draft
feat: add LangChain Runner protocol implementation (AIC-2388)#1338jsonbailey wants to merge 1 commit intojb/aic-2388/js-openai-runnerfrom
jsonbailey wants to merge 1 commit intojb/aic-2388/js-openai-runnerfrom
Conversation
Adds LangChainModelRunner, LangChainAgentRunner, and LangChainRunnerFactory that implement the Runner protocol introduced in JS PR 6. The runners return RunnerResult instead of the legacy ChatResponse / StructuredResponse. 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>
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
Adds Runner-protocol classes for the LangChain provider, mirroring the OpenAI runner work in JS PR 7. New classes:
LangChainModelRunner—Runnerfor chat completions;run(messages, outputType?)returnsRunnerResult { content, metrics, raw, parsed? }. Structured output is parsed viawithStructuredOutputand exposed onparsed.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 the model invoked.LangChainRunnerFactory— exposescreateModel(config)andcreateAgent(config, tools?).convertMessagesToLangChain,mapProviderName,getAIMetricsFromResponse,getAIUsageFromResponse— helper functions.mapProvideris renamed tomapProviderNameon both the helper module and theLangChainProviderclass; the old name is preserved as a@deprecatedalias so existing callers continue to work.The legacy
LangChainProviderclass is preserved soAIProviderFactory(also@deprecated) keeps working until the managed layer fully migrates toRunner.run().Stacked on
jb/aic-2388/js-openai-runner(JS PR 7).Test plan
yarn workspace @launchdarkly/server-sdk-ai-langchain test— 37 tests pass (existing 16 + 21 new)yarn workspace @launchdarkly/server-sdk-ai-langchain lint— cleanyarn workspace @launchdarkly/server-sdk-ai-langchain run build— clean🤖 Generated with Claude Code