Overview
The LangchainAgent bridges AG-Kit with LangChain’s createAgent runtime. It reuses the LanggraphAgent event model under the hood (compiledWorkflow = agent), so it streams the same BaseEvent types and works seamlessly with @ag-kit/server. Key capabilities:- Wraps a LangChain agent created via createAgent
- Streams AG-UI compatible events (text chunks, tool calls, results)
- Adds client-supplied tools to model calls via the agKitClientTools middleware
Installation
Exports
All exports are available from@ag-kit/adapter-langchain:
Exports:
- LangchainAgent – Main agent class for LangChain integration
- agKitClientTools – Middleware to inject client tools into LangChain model calls
- convert2LangChain – Convert an AG‑Kit BaseTool to a LangChain DynamicStructuredTool
- convertLangChain2AGKit – Convert a LangChain StructuredTool to an AG‑Kit Dynamic Tool
Quick start
Server integration
Using AG‑Kit tools with LangChain
agKitClientTools makes your client-provided tools available to the underlying LangChain model call (request.tools). Any tools passed to agent.run(…) will be appended as DynamicStructuredTool definitions.API
class LangchainAgent
Unique identifier for the agent.
Human-readable description of the agent.
LangChain agent instance returned by
createAgent. It is passed to the base LanggraphAgent as compiledWorkflow.Methods
run()
- input – RunAgentInput containing messages, runId, threadId, tools, etc.
- returns –
Observable<BaseEvent>
Note: Event types and semantics are identical to LanggraphAgent. See LangGraph Agent for the full event list.
agKitClientTools()
Adds client-provided tools from
state.agKit.actions into LangChain’s request.tools for the model call.Tool conversion helpers
- convert2LangChain – Wrap an AG‑Kit tool for use with LangChain
- convertLangChain2AGKit – Wrap a LangChain tool for use with AG‑Kit
See also
- LangGraph Agent: /reference/agents/adapters/langgraph
- Core agent reference: /reference/agents/agents
- Server integration: /reference/server/overview