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/langgraph

Available 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

ParameterTypeDescription
graphCompiledGraphThe LangGraph compiled graph
namestringName for the Reminix agent
outputKeystringKey to extract from final state (optional)
metadataobjectOptional metadata for the agent

Handler Mapping

Reminix HandlerLangGraph Method
onInvokegraph.invoke()
onInvokeStreamgraph.stream()
onChatgraph.invoke() with messages
onChatStreamgraph.stream() with messages

On this page