@pmcollab/coworkstream-engine-langgraph
v0.1.0
Published
LangGraph (LangChain.js) AgentRunner adapter for @pmcollab/coworkstream-engine.
Readme
@pmcollab/coworkstream-engine-langgraph
Coding agents: read
packages/workstream-engine/AGENTS.mdfor the engine integration recipe before wiring this adapter. Migrating an existing setup? Seepackages/workstream-engine/MIGRATION.md.
LangGraph (LangChain.js) AgentRunner adapter for @pmcollab/coworkstream-engine. Wraps a compiled graph as a workstream agent.
Install
npm install @pmcollab/coworkstream-engine-langgraph @langchain/langgraphUse
import { StateGraph, MessagesAnnotation } from '@langchain/langgraph'
import { ChatAnthropic } from '@langchain/anthropic'
import { createLangGraphAgent } from '@pmcollab/coworkstream-engine-langgraph'
const llm = new ChatAnthropic({ model: 'claude-sonnet-4-6' })
const graph = new StateGraph(MessagesAnnotation)
.addNode('reason', async (state) => ({ messages: [await llm.invoke(state.messages)] }))
.addEdge('__start__', 'reason')
.addEdge('reason', '__end__')
.compile()
const agent = createLangGraphAgent({
id: 'reasoner',
graph,
toInput: (item) => ({
messages: [{ role: 'user', content: `Decide on: ${item.title}` }],
}),
extractPosition: (state) => {
const last = state.messages[state.messages.length - 1]?.content ?? ''
return {
position: /approve/i.test(last) ? 'approve' : 'reject',
reasoning: last,
confidence: 0.7,
}
},
})Why
LangGraph is the durable, stateful agent runtime in the LangChain ecosystem. Use this adapter when:
- You're already using LangGraph for multi-step agent workflows
- You want checkpointing/persistence of agent state
- Your agents call multiple tools / sub-graphs before reaching a decision
Options
createLangGraphAgent({
id, graph, // required
name?, avatar?, capabilities?,
toInput?: (item, ctx) => unknown,
extractPosition?: (state, item, ctx) => { position, reasoning, confidence },
config?: unknown, // passed to graph.invoke as 2nd arg
defaultConfidence?: number,
})License
Commercial. See LICENSE in the repository root.
