LangGraph.js
Wrap LangGraph.js stateful workflows for use with the Reminix runtime
The LangGraph.js adapter wraps LangGraph's stateful, graph-based workflows for use with the Reminix runtime.
Installation
npm install @reminix/runtime @reminix/adapters @langchain/langgraph
# or
pnpm add @reminix/runtime @reminix/adapters @langchain/langgraphAvailable Adapters
fromCompiledGraph
Wrap a compiled LangGraph (result of StateGraph.compile()):
import { StateGraph, MessagesAnnotation } from '@langchain/langgraph';
import { fromCompiledGraph } from '@reminix/adapters/langgraph';
import { serve } from '@reminix/runtime';
const graph = new StateGraph(MessagesAnnotation)
.addNode('agent', async (state) => {
// Your agent logic here
const response = await model.invoke(state.messages);
return { messages: [response] };
})
.addEdge('__start__', 'agent')
.addEdge('agent', '__end__')
.compile();
const agent = fromCompiledGraph(graph, { name: 'workflow' });
serve(agent);Works with LangChain's createAgent()
Since LangChain's modern createAgent() returns a compiled graph, you can also use fromCompiledGraph with it:
import { createAgent } from 'langchain';
import { fromCompiledGraph } from '@reminix/adapters/langgraph';
import { serve } from '@reminix/runtime';
// createAgent returns a CompiledGraph
const lcAgent = createAgent({
model: 'openai:gpt-4o',
tools: [searchTool, calculatorTool],
});
const agent = fromCompiledGraph(lcAgent, { name: 'smart-agent' });
serve(agent);Options
| Parameter | Type | Description |
|---|---|---|
graph | CompiledGraph | The LangGraph compiled graph |
name | string | Name for the Reminix agent |
outputKey | string | Key to extract from final state (optional) |
metadata | object | Optional metadata for the agent |
Handler Mapping
| Reminix Handler | LangGraph Method |
|---|---|
onInvoke | graph.invoke() |
onInvokeStream | graph.stream() |
onChat | graph.invoke() with messages |
onChatStream | graph.stream() with messages |