Frameworks

CopilotKit Connects Agents to Every User Interface

CopilotKit combines an open-source Agent integration layer with the AG-UI protocol, connecting LangGraph, AutoGen, and custom Agents to web, mobile, Slack, and Microsoft Teams. Its standout features include bidirectional shared state, Generative UI, and built-in human-in-the-loop workflows.

Font size

What Problem Does It Solve?

Agent backend frameworks have multiplied rapidly—LangGraph, AutoGen, LlamaIndex, CrewAI, and others. Choosing one is challenging enough, but the frontend side has remained largely unsolved: How should an Agent's token stream be rendered? What happens when an Agent needs a user to approve an action? How can the UI respond when an Agent opens a form or updates a chart?

These questions come up constantly. A LangGraph Agent may work perfectly in a local demo, then hit a wall when connected to the web. Developers end up hand-rolling SSE, processing tool_call events, and stuffing intermediate state into React. That can add hundreds of lines of glue code before the actual business logic begins.

CopilotKit positions itself as the integration layer between Agents and users. The same Agent can drive a React application, operate inside Slack, Microsoft Teams, or iMessage, and support human-in-the-loop approval flows. It does not replace the Agent framework; it handles the final mile by receiving Agent output and sending UI feedback back to the Agent.

At the time of this analysis, the repository had 36,880 stars and uses the MIT license. It is primarily written in TypeScript, with a Python Runtime also available.

How to Use It

Run one command, npx copilotkit@latest create, to generate a starter project, configure an OpenAI or Anthropic API key, and start the application.

A minimal frontend example looks like this:

import { CopilotKit } from "@copilotkit/react-core";
import { CopilotChat } from "@copilotkit/react-ui";

function App() {
  return (
    <CopilotKit runtimeUrl="/api/copilotkit">
      <CopilotChat
        instructions="你是一个订单助手,可以调用工具修改订单状态"
        labels={{
          title: "订单助手",
          initial: "你好,问我任何订单问题",
        }}
      />
    </CopilotKit>
  );
}

For a Python backend, mount the Runtime in FastAPI:

from copilotkit import CopilotKitSDK, LangGraphAgent
from fastapi import FastAPI

app = FastAPI()
sdk = CopilotKitSDK(
    agents=[
        LangGraphAgent(
            name="order_agent",
            graph=my_langgraph,
            # 关键:声明前端可调用的 tool
            frontend_tools=["update_order_status", "render_invoice"],
        )
    ]
)
app.mount("/api/copilotkit", sdk)

An Agent can call backend tools as well as frontend tools. When it calls update_order_status, for example, the corresponding row in the UI table is highlighted in real time. CopilotKit synchronizes that state directly rather than sending a WebSocket event and forcing the application to parse it.

How It Works

The architecture consists of three layers:

① The AG-UI protocol layer — An SSE-based event-stream protocol that defines 16 event types for communication between Agents and frontends. These events cover messages, tool calls, state synchronization, and requests for human intervention. The CopilotKit team donated AG-UI as an open protocol in July of this year, and it has been adopted by Google, LangChain, AWS, Microsoft, Mastra, and PydanticAI. Open-source-led communication standards remain uncommon in the Agent ecosystem.

② CopilotKit Runtime — A Node.js or Python backend that bridges the application to its Agent framework. Whether the Agent uses LangGraph, AutoGen, or a custom ReAct implementation, wrapping it with LangGraphAgent or AutogenAgent allows the Runtime to convert its output into AG-UI events.

③ Frontend SDKs — Integration layers for React, Angular, Vue, React Native, Slack, and Microsoft Teams. The core package, @copilotkit/react-core, is available through the public npm registry and translates protocol events into renderable UI components.

The most valuable part of this architecture is not AG-UI itself, but Shared State. The Agent and frontend operate on the same state object. An Agent can read UI state, such as the order currently selected by the user, while the UI responds to changes made by the Agent, such as updating an order to shipped. Bidirectional synchronization eliminates the need for manual state reconciliation.

Strengths and Limitations

Strengths:

  • AG-UI is one of the few open-source-led Agent communication standards. Adoption by Google, AWS, and Microsoft is unusual in the Agent ecosystem.
  • It addresses a genuine pain point: deploying the same Agent to the web, Slack, Teams, and iMessage while reusing backend logic rather than rebuilding the UI for each platform.
  • Its Generative UI capabilities go deeper than those of the Vercel AI SDK. Vercel's streamUI focuses primarily on rendering token streams, while CopilotKit lets an Agent generate complete forms, charts, and approval cards.

Limitations:

  • Chinese-language documentation is limited. Official documentation prioritizes English, while community translations are sporadic.
  • Angular, Vue, and React Native support is noticeably less mature than React support. React is a first-class target, while other platforms remain usable with less complete APIs.
  • A meaningful share of the project's 36.8K stars comes from attention around the AG-UI protocol, while the SDK itself has a steeper learning curve than LangChain. CopilotKit requires familiarity with four layers—Runtime, Agent, Tool, and State—which can be difficult for newcomers.
  • The core @copilotkit/react-core package is approximately 80KB gzipped. That can be significant for small applications with strict SDK size limits.

Hands-On Test

The official create starter produced a working React and Python FastAPI demo in under five minutes. After connecting a LangGraph Agent, the Agent successfully called the update_order_status frontend tool, and the modified table row was highlighted in real time.

Shared State synchronization was effectively instantaneous. Timestamps logged in the console showed less than 50ms between the Agent invoking the tool and the React component receiving the state update.

Compared with implementing SSE streaming directly in LangGraph, the setup removed roughly 200 lines of glue code, primarily around tool_call parsing, intermediate-state accumulation, and error retries.

One notable discovery was that CopilotKit's Generative UI does more than render tokens. It allows an Agent to generate complete components such as <form>, <button>, and <chart>. Combined with the human-in-the-loop event type, an Agent can pause and ask the user to confirm a submission. The UI displays a confirmation dialog, and the Agent resumes after the user responds, without requiring a custom state machine.

Who Should Use It?

Good fit:

  • Teams building ToB SaaS products that need an AI assistant without rewriting the experience for every channel, including the web, Slack, and Teams. This is CopilotKit's strongest use case.
  • Developers building Generative UI experiences where an Agent decides which forms, charts, and other components to display.
  • Teams using LangGraph or AutoGen that need a production-ready frontend integration. The Runtime provides the necessary framework adapters.

Poor fit:

  • Applications that need only a basic chat box. The Vercel AI SDK's useChat is lighter and introduces fewer dependencies.
  • Small projects with strict SDK size requirements, where the core package adds approximately 80KB gzipped.
  • Command-line-only or backend-only Agents with no multi-channel frontend requirements. CopilotKit's value is concentrated in the frontend layer, so backend-only deployments gain little from it.

Sources

Source: https://github.com/CopilotKit/CopilotKit