Skip to content

feat: add LangChain Runner protocol implementation (AIC-2388)#1338

Draft
jsonbailey wants to merge 1 commit intojb/aic-2388/js-openai-runnerfrom
jb/aic-2388/js-langchain-runner
Draft

feat: add LangChain Runner protocol implementation (AIC-2388)#1338
jsonbailey wants to merge 1 commit intojb/aic-2388/js-openai-runnerfrom
jb/aic-2388/js-langchain-runner

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

Summary

Adds Runner-protocol classes for the LangChain provider, mirroring the OpenAI runner work in JS PR 7. New classes:

  • LangChainModelRunnerRunner for chat completions; run(messages, outputType?) returns RunnerResult { content, metrics, raw, parsed? }. Structured output is parsed via withStructuredOutput and exposed on parsed.
  • LangChainAgentRunnerRunner for a single agent. Runs a tool-calling loop using LangChain's native bindTools and ToolMessage. Tool definitions come from config.model.parameters.tools; tool callables come from a caller-supplied ToolRegistry. Populates LDAIMetrics.toolCalls with the names of tools the model invoked.
  • LangChainRunnerFactory — exposes createModel(config) and createAgent(config, tools?).
  • convertMessagesToLangChain, mapProviderName, getAIMetricsFromResponse, getAIUsageFromResponse — helper functions.

mapProvider is renamed to mapProviderName on both the helper module and the LangChainProvider class; the old name is preserved as a @deprecated alias so existing callers continue to work.

The legacy LangChainProvider class is preserved so AIProviderFactory (also @deprecated) keeps working until the managed layer fully migrates to Runner.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 — clean
  • yarn workspace @launchdarkly/server-sdk-ai-langchain run build — clean

🤖 Generated with Claude Code

@jsonbailey jsonbailey force-pushed the jb/aic-2388/js-openai-runner branch from 07f1af2 to 66bb862 Compare May 1, 2026 14:10
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>
@jsonbailey jsonbailey force-pushed the jb/aic-2388/js-langchain-runner branch from 7a6a7b8 to 58f8249 Compare May 1, 2026 14:13
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.

1 participant