Overview
TheLanggraphAgent integrates AG-Kit with LangGraph workflows. It streams execution events, maps AG-UI messages to LangGraph messages, exposes AG-Kit tools to LangGraph via state.agKit.actions, and supports checkpointing (in-memory or TDAI-backed).
Installation
@langchain/openai– if you use OpenAI models (e.g.,ChatOpenAIin examples)
Exports
All exports are available from@ag-kit/adapter-langgraph:
LanggraphAgent- Main agent class for LangGraph integrationAGKitStateAnnotation- State annotation for LangGraph workflowsAGKitPropertiesAnnotation- Properties annotation containing AG-Kit actionstype AGKitState- TypeScript type for the AG-Kit state structureTDAISaver- Checkpoint saver implementation using TDAI Memorytype TDAISaverConfig- Configuration type for TDAISaver
Quick start
Server integration
Pass the agent to the server. The server exposes aPOST /send-message SSE endpoint.
Using AG-Kit Tools in Workflows
AG-Kit tools are automatically exposed to your LangGraph workflow viastate.agKit.actions. You can access these tools in your workflow nodes:
Note: Thestate.agKit.actionsarray contains tool definitions that are automatically populated from the tools passed toagent.run(). These are already converted to a format compatible with LangGraph workflows.
Checkpointing
TheLanggraphAgent supports checkpointing for state persistence. You can use in-memory checkpointing or TDAI-backed checkpointing:
In-memory checkpointing:
API
class LanggraphAgent
TheLanggraphAgent class integrates AG-Kit with LangGraph workflows, providing event streaming, message mapping, and tool exposure.
Unique identifier for the agent.
Human-readable description of the agent.
Compiled LangGraph workflow to execute. Typically created via
workflow.compile(…). Must use AGKitStateAnnotation as the state schema.Methods
run()
BaseEvent values from @ag-ui/client during execution.
Parameters:
input-RunAgentInputobject containing messages, run ID, thread ID, tools, and other configuration
Observable<BaseEvent>- RxJS Observable that emits execution events
Event types
The agent emits the following event types during execution:RUN_STARTED- Emitted when execution beginsRUN_FINISHED- Emitted when execution completes (may includeoutcome: 'interrupt'andinterruptpayload for interrupted runs)RUN_ERROR- Emitted when an error occurs during executionTEXT_MESSAGE_START- Emitted when a text message beginsTEXT_MESSAGE_CONTENT- Emitted for each chunk of message content (supports streaming)TEXT_MESSAGE_END- Emitted when a text message completesTOOL_CALL_START- Emitted when a tool call beginsTOOL_CALL_ARGS- Emitted for tool call arguments (supports streaming deltas)TOOL_CALL_END- Emitted when a tool call completesTOOL_CALL_RESULT- Emitted with the result of a tool call
Tip: In most applications you don’t need to handle these events directly. @ag-kit/server consumes them from the agent and streams them over SSE for you.
AGKitStateAnnotation
TheAGKitStateAnnotation provides the state schema for LangGraph workflows. It includes:
messages- Array of LangGraph messagesagKit.actions- Array of AG-Kit tools exposed to the workflow
TDAISaver
TheTDAISaver class provides checkpoint persistence using TDAI Memory storage.
Collection name for storing checkpoints. Default:
“checkpoints”Collection name for storing checkpoint writes. Default:
“checkpoint_writes”Additional TDAI Memory client configuration options. See TDAI Memory documentation for details.
Best Practices
- Use AGKitStateAnnotation: Always use
AGKitStateAnnotationas your state schema to enable AG-Kit integration - Access Tools from State: Use
state.agKit.actionsto access AG-Kit tools in your workflow nodes - Checkpointing: Use checkpointing for state persistence in production applications
- Error Handling: Handle
RUN_ERRORevents appropriately in your application - Streaming: Leverage event streaming for real-time user feedback
See also
- Core agent reference:
/reference/agents/agents - Server integration:
/reference/server/overview - Server events:
/reference/server/events - LangGraph documentation: LangGraph TypeScript Docs