Summary
In @copilotkit/runtime versions 1.50.0 and later, using LangChainAdapter (or any custom CopilotServiceAdapter that doesn't define provider/model properties) causes the runtime to crash with an Unknown provider "undefined" error.
Furthermore, the new architecture attempts to wrap the adapter in a BuiltInAgent, which completely bypasses the adapter's process() method. This means custom chainFn logic in LangChainAdapter is ignored, breaking all custom LangChain/LangGraph integrations that rely on the v1 adapter pattern.
♻️ Reproduction Steps
- Initialize
CopilotRuntime with a LangChainAdapter.
const serviceAdapter = new LangChainAdapter({
chainFn: async ({ messages, tools }) => {
// Custom LangChain logic
return model.stream(messages);
}
});
const runtime = new CopilotRuntime();
// Mount endpoint
const handler = copilotRuntimeNodeExpressEndpoint({
endpoint: "/copilotkit",
runtime,
serviceAdapter,
});
- Send a message to the chat endpoint.
✅ Expected Behavior
The runtime should delegate execution to serviceAdapter.process(), allowing the LangChainAdapter to execute its chainFn and stream the response back to the client.
❌ Actual Behavior
The runtime crashes immediately with the following error:
Agent execution failed: Error: Unknown provider "undefined" in "undefined/undefined". Supported: openai, anthropic, google (gemini).
at resolveModel (.../node_modules/@copilotkitnext/agent/src/index.ts:208:13)
...
𝌚 CopilotKit Version
## Environment
- **Package:** `@copilotkit/runtime`
- **Version:** `1.50.0` - `1.51.4` (Current)
- **Adapter:** `LangChainAdapter` (or any custom adapter)
- **Framework:** Node.js / Express / Hono
📄 Logs (Optional)
Root Cause Analysis
1. Invalid Model Resolution
In packages/v1/runtime/src/lib/runtime/copilot-runtime.ts, the handleServiceAdapter method attempts to convert legacy adapters into the new BuiltInAgent architecture. It constructs a model string by reading properties that do not exist on LangChainAdapter:
// copilot-runtime.ts
agentsList.default = new BuiltInAgent({
// LangChainAdapter does not have .provider or .model properties
model: ${serviceAdapter.provider}/${serviceAdapter.model},
});
This results in the string "undefined/undefined", which causes resolveModel in @copilotkitnext/agent to throw.
2. Execution Logic Bypass (Critical)
Even if the model string were valid (e.g., by patching the adapter), BuiltInAgent uses the Vercel AI SDK's streamText directly. It does not call serviceAdapter.process().
This means the core functionality of LangChainAdapter—executing the user-defined chainFn—is completely unreachable in the new architecture. The runtime effectively discards the custom logic provided in the adapter.
Impact
- Blocker: Users cannot upgrade to v1.50+ if they use
LangChainAdapter or custom adapters.
- Functionality Loss: Custom chains, RAG pipelines, and LangGraph workflows defined via
chainFn are non-functional.
Summary
In
@copilotkit/runtimeversions 1.50.0 and later, usingLangChainAdapter(or any customCopilotServiceAdapterthat doesn't defineprovider/modelproperties) causes the runtime to crash with anUnknown provider "undefined"error.Furthermore, the new architecture attempts to wrap the adapter in a
BuiltInAgent, which completely bypasses the adapter'sprocess()method. This means customchainFnlogic inLangChainAdapteris ignored, breaking all custom LangChain/LangGraph integrations that rely on the v1 adapter pattern.♻️ Reproduction Steps
CopilotRuntimewith aLangChainAdapter.✅ Expected Behavior
The runtime should delegate execution to
serviceAdapter.process(), allowing theLangChainAdapterto execute itschainFnand stream the response back to the client.❌ Actual Behavior
The runtime crashes immediately with the following error:
𝌚 CopilotKit Version
📄 Logs (Optional)
Root Cause Analysis
1. Invalid Model Resolution
In
packages/v1/runtime/src/lib/runtime/copilot-runtime.ts, thehandleServiceAdaptermethod attempts to convert legacy adapters into the newBuiltInAgentarchitecture. It constructs a model string by reading properties that do not exist onLangChainAdapter:// copilot-runtime.ts
agentsList.default = new BuiltInAgent({
// LangChainAdapter does not have .provider or .model properties
model:
${serviceAdapter.provider}/${serviceAdapter.model},});
This results in the string
"undefined/undefined", which causesresolveModelin@copilotkitnext/agentto throw.2. Execution Logic Bypass (Critical)
Even if the model string were valid (e.g., by patching the adapter),
BuiltInAgentuses the Vercel AI SDK'sstreamTextdirectly. It does not callserviceAdapter.process().This means the core functionality of
LangChainAdapter—executing the user-definedchainFn—is completely unreachable in the new architecture. The runtime effectively discards the custom logic provided in the adapter.Impact
LangChainAdapteror custom adapters.chainFnare non-functional.