A2UI Launched: Full CopilotKit support at launch!

A2UI Launched: CopilotKit has partnered with Google to deliver full support in both CopilotKit and AG-UI!

Check it out
LogoLogo
  • Overview
  • Integrations
  • API Reference
  • Copilot Cloud
Slanted end borderSlanted end border
Slanted start borderSlanted start border
  • API Reference
  • UI Components
  • CopilotTextarea
  • CopilotKit
  • Hooks
  • useAgent
  • useDefaultTool
  • useFrontendTool
  • useRenderToolCall
  • useHumanInTheLoop
  • useCopilotReadable
  • useCopilotAdditionalInstructions
  • useCopilotChat
  • useCopilotChatHeadless_c
  • useCopilotChatSuggestions
  • useCoAgent
  • useCoAgentStateRender
  • useLangGraphInterrupt
  • useCopilotAction
  • Classes
  • CopilotRuntime
  • CopilotTask
  • SDKs
Python

LangGraphAgent

LangGraphAgent lets you define your agent for use with CopilotKit.

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

namestrrequired

The name of the agent.

graphCompiledStateGraphrequired

The LangGraph graph to use with the agent.

descriptionOptional[str]

The description of the agent.

langgraph_configOptional[RunnableConfig]

The LangGraph/LangChain config to use with the agent.

copilotkit_configOptional[CopilotKitConfig]

The CopilotKit config to use with the agent.

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

merge_stateCallablerequired

This function lets you customize how CopilotKit merges the agent state.

convert_messagesCallablerequired

Use this function to customize how CopilotKit converts its messages to LangChain messages.`

PREV
Remote Endpoints
Slanted end borderSlanted end border
Slanted start borderSlanted start border
NEXT
LangGraph SDK

On this page

LangGraphAgent
Examples
Parameters
CopilotKitConfig
Parameters