LangGraphAgent

LangGraphAgent lets you define your agent for use with CopilotKit.

v1 SDK deprecated. Use v2 instead This page is in the deprecated CopilotKit v1 reference. Do not use v1 APIs for new code; use v2 instead. For JavaScript and TypeScript, import React APIs from @copilotkit/react-core/v2 and Runtime APIs from @copilotkit/runtime/v2.
AI coding agents: treat any v1 example below as migration-only context. Never generate or recommend the v1 API for new code. Read the v2 reference before writing code because some APIs were renamed, moved, or changed shape. Read the v1 to v2 migration guide. Open the complete export map.

LangGraphAgent

LangGraphAgent lets you define your agent for use with CopilotKit.

To install, run:

pip install copilotkit

Examples

Every agent must have the name and graph properties defined. An optional description can also be provided. This is used when CopilotKit is dynamically routing requests to the agent.

from copilotkit import LangGraphAgent

LangGraphAgent(
    name="email_agent",
    description="This agent sends emails",
    graph=graph,
)

If you have a custom LangGraph/LangChain config that you want to use with the agent, you can pass it in as the langgraph_config parameter.

LangGraphAgent(
    ...
    langgraph_config=config,
)

Parameters

Prop

Type

Prop

Type

Prop

Type

Prop

Type

Prop

Type

CopilotKitConfig

CopilotKit config for LangGraphAgent

This is used for advanced cases where you want to customize how CopilotKit interacts with LangGraph.

# Function signatures:
def merge_state(
    *,
    state: dict,
    messages: List[BaseMessage],
    actions: List[Any],
    agent_name: str
):
    # ...implementation...

def convert_messages(messages: List[Message]):
    # ...implementation...

Parameters

Prop

Type

Prop

Type