Agent adapters
Choose the SDK that runs an agent with its runtime field, keep SDK-specific options in the adapter, and bind models through profiles.
This page continues Define an agent, which installs the LangChain adapter. An agent’s runtime field names the adapter that executes it. RelKit owns everything around the
model call: tools run through the common function engine, the engine’s access rules apply, threads
are durable, approvals pause and resume the run, events stream as AG-UI, and traces record each run.
The adapter supplies the model turn.
Two adapters ship with RelKit. Both are Core: the interface is stable at protocol version 1, and each adapter supports a range of SDK versions.
| Adapter | Package | Value |
|---|---|---|
| LangChain | @relkit/langchain |
langchain() |
| Vercel AI SDK | @relkit/ai-sdk |
aiSdk() |
Only adapter packages in the @relkit scope are loaded. The server imports @relkit/<id>/runtime
for the adapter each agent names, so an adapter published under another scope is not loaded.
What the stable interface covers
From the move to Core, semantic versioning covers the names and shapes RelKit defines:
relkit/agent-adapters: the adapter interface at protocol version 1, the shared loop, the tool bridge and the AG-UI mapping;@relkit/langchain:langchain()and its options, graph workflows (defineGraph,defineGraphNode, edges, subgraphs, interrupts),defineCheckpointerDb,defineMemoryDb,langchainModeland the./testingentry;@relkit/ai-sdk:aiSdk(), its options andaiSdkModel.
A value whose type comes from the SDK, such as a LangChain middleware, a LangGraph saver or an AI SDK model, follows that SDK within the supported versions below.
Supported and tested versions
Each adapter accepts a range of its SDK’s versions. relkit check, relkit build and the server at
start read the installed versions:
| Package | Supported | Tested through | Package that needs it |
|---|---|---|---|
langchain |
1.5.10 up to 2.0 | 1.6.8 | @relkit/langchain |
@langchain/core |
1.2.9 up to 2.0 | 1.5.1 | @relkit/langchain |
@langchain/langgraph |
1.4.14 up to 2.0 | 1.7.5 | @relkit/langchain |
deepagents |
1.13.3 up to 2.0 | 1.17.1 | @relkit/langchain |
langsmith |
0.10.8 up to 1.0 | 0.14.0 | @relkit/langchain |
ai |
7.0.153 up to 8.0 | 7.0.184 | @relkit/ai-sdk |
- A version from the lower bound through “tested through” is accepted.
- A newer version below the upper bound runs, with the warning
RELKIT_DEPENDENCY_VERSION_UNTESTED. - A version outside the range fails with
RELKIT_DEPENDENCY_VERSION_UNSUPPORTED.
CI runs the agent suites on Bun, Node 22 and Node 24 with the versions the installation snippets
install. A daily job runs them with the lower bound and with the newest version in the range. The LangGraph
checkpointer and store drivers have ranges as well, but relkit check does not read their versions.
Where agents run
Agents run on Bun and Node. On Cloudflare Workers, relkit check reports
RELKIT_WORKERS_PROVIDER_UNSUPPORTED for the
agent-state profile with every provider; deploy an application with agents to a target that runs
Bun or Node. The agent-state profile uses the local provider or Redis; see
Agent state on Redis for the load it is
tested to handle.
For graph workflows and DeepAgents, the LangGraph checkpointer and store are your drivers:
- RelKit never calls a driver’s
.setup()and never runs its migrations. RedisStoredoes not satisfydefineMemoryDb’s types with the tested versions, so a Redis memory store is not supported; Redis checkpointers are.- A step resumed after an interrupt starts from its beginning.
See LangGraph, persistence, and resume for the supported drivers.
Select an adapter
import { defineAgent } from "relkit/agents";
import { langchain } from "@relkit/langchain";
import { s } from "relkit/schema";
export default defineAgent({
id: "hello.support",
runtime: langchain(),
model: "default",
input: s.object({ message: s.string() }),
output: s.object({ answer: s.string() }),
instructions: "Answer briefly.",
tools: [],
limits: { maxSteps: 4, maxToolCalls: 4, timeoutMs: 30_000 },
});
An agent that uses no adapter-specific options switches adapters by changing runtime alone, for
example to aiSdk() from @relkit/ai-sdk. Applications that never select the AI SDK adapter
install no AI SDK package, and an application whose agents all use aiSdk() installs no LangChain
package. See AI SDK adapter for that adapter’s model profiles and limits,
and DeepAgents for subagents, skills, memory and interrupts.
Keep SDK options in the adapter
Native models, middleware, tools, persistence and DeepAgents capabilities go in the adapter’s own
options, such as langchain({ middleware: [todoListMiddleware()] }). Those options tie the agent to
that adapter: client.state keys contributed by LangChain middleware type-check only under
langchain(), and defineAgent rejects native fields placed beside the portable ones. See
LangChain adapter and DeepAgents for every LangChain option.
Bind models through profiles
model names a model profile bound in relkit.config.ts; omitted, the agent uses the default
profile. Rebinding the profile moves every agent that uses it to the new model without code changes.
import { defineApp } from "relkit/config";
import { langchainModel } from "@relkit/langchain";
import env from "@app/platform/env.js";
export default defineApp({
env,
model: { default: langchainModel({ model: "openai:gpt-5" }) },
defaults: { model: "default" },
});
model: "default:gpt-5-mini" keeps the profile’s provider and overrides the model name for one agent.
Write an adapter
relkit/agent-adapters holds the interface. An adapter package exports two halves:
- its authoring value, built with
defineAgentRuntime, which loads no SDK; - its runtime half, built with
createAgentAdapterRuntime({ adapterId, turn }), whereturnruns one model call with the bridged tool definitions. It returns the turn’s text and tool calls, or yields them as{ kind: "text", delta }and{ kind: "tool-call", call }parts while the model produces them, so the run streams its text.
RelKit’s shared loop calls turn and implements run, stream, resume and stop. Its tool bridge
(createAgentToolBridge) runs approvals and the engine’s access check before each tool reaches the
engine, and agUiEvents maps every stream frame to AG-UI events.
Run the conformance suite
@relkit/testing/agents-conformance runs the same cases against any adapter: tools, approvals, threads,
streaming, text that streams within a turn, access rules, traces and model profiles. Both
first-party adapters pass it.
import { createAgentConformanceHarness } from "@relkit/testing/agents-conformance";
import { test } from "vitest";
import { myAdapter, myAdapterRuntime, scriptedModel } from "../src/index.js";
const harness = createAgentConformanceHarness({
adapter: () => myAdapter(),
runtime: myAdapterRuntime,
scriptedModel,
});
for (const item of harness.cases) test(item.description, () => harness.run(item.id));
Reference: Agent adapters API, LangChain API, AI SDK API.