Back to Copilotkit

Channels Agent Setup

showcase/integrations/langgraph-python/docs/setup/channels-agent-setup.mdx

1.64.2929 B
Original Source

Follow the LangGraph Python quickstart to configure the sample_agent graph. Start its existing LangGraph server:

bash
npx @langchain/langgraph-cli dev --port 8123 --no-browser

Point the native LangGraph adapter at that deployment:

dotenv
LANGGRAPH_DEPLOYMENT_URL=http://localhost:8123

The Runtime package installed by the Channels quickstart includes the native LangGraph adapter.

LangGraph Server speaks the LangGraph API, so use LangGraphAgent rather than HttpAgent. Return a fresh adapter for every channel thread:

ts
import { LangGraphAgent } from "@copilotkit/runtime/langgraph";

export function makeAgent(threadId: string) {
  const agent = new LangGraphAgent({
    deploymentUrl: process.env.LANGGRAPH_DEPLOYMENT_URL!,
    graphId: "sample_agent",
  });
  agent.threadId = threadId;
  return agent;
}