mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
1b028f484c
## Problem
A starter scaffolded with `copilotkit init --framework mastra` and
connected to managed Intelligence starts, accepts a chat message, and
never answers. `POST /api/copilotkit/agent/default/run` still returns
200, so the abort is only visible in the server log:
```
Agent execution failed: Error: Thread c883919e-… not found
```
## Root cause
`@ag-ui/mastra`'s `syncInputStateToWorkingMemory` writes the UI's shared
state into Mastra working memory **before** it streams a turn. That
write is unguarded and never creates the thread, because it assumes the
resource-scoped store, which upserts. Its own comment says so, and its
*remote* branch handles the opposite case explicitly ("requires the
thread to exist… create the thread and retry once").
This starter was the one Mastra agent in the repo that set
`workingMemory.scope: "thread"`. Thread scope routes the same write to
thread metadata, and `@mastra/memory` throws `Thread <id> not found`
when the thread row does not exist. On the first turn of a conversation
it never does, so the run dies before the model is called.
Managed Intelligence made that certain rather than likely:
`handlers/intelligence/run.ts` replaces the client thread id with a
platform-canonical one from `ɵacquireThreadLock`, which the Mastra store
has never seen. That also explains the two different thread ids in the
same failure.
## Evidence
Verified by running, against the starter's exact pins (`@mastra/core`
1.41.0, `@mastra/memory` 1.0.1-alpha.1, `@ag-ui/mastra` 1.1.2):
| Configuration | First-turn state sync |
| --- | --- |
| `scope: "thread"` (as shipped) | throws `Thread <id> not found`, run
aborts |
| `scope: "resource"` | writes, reads back, reaches the agent's system
message |
Resource scope keeps working memory **per conversation** here, because
the bridge derives the resource id from the thread id when no explicit
resource id is configured. Confirmed: a second thread id reads back
`null`, and schema merge semantics still work on turn 2.
## Change
- `examples/integrations/mastra` uses `scope: "resource"`, matching
every other Mastra agent in this repo, with a comment explaining why.
- A new contract test in
`scripts/__tests__/integration-intelligence-migration.test.ts` fails if
any integration starter configures thread-scoped Mastra working memory.
It asserts the mastra starter is in scope, so it cannot pass vacuously,
and it ships with five helper cases including a decoy
(`observationalMemory.scope: "thread"`, which is unrelated and must not
trip it).
This also fixes the Channel host, which drives the same agent.
## Verification
- `vitest run
scripts/__tests__/integration-intelligence-migration.test.ts` — 159
passed, and the new test is red on the unfixed starter (`expected [
'mastra/src/mastra/agents/index.ts' ] to deeply equal []`).
- `parity:check` passes, `oxlint` and `oxfmt --check` clean.
## Left undone, deliberately
The adapter's local branch is still unguarded, so a developer who
chooses thread scope hits the same abort in their own code. The fix
belongs in `@ag-ui/mastra` and mirrors what its remote branch already
does. That needs an ag-ui PR plus a release, so it is not in this
change.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Updated the weather agent’s working-memory scope to support shared UI
state during the first turn of a conversation.
* Prevented conversation initialization issues caused by thread-scoped
memory.
* **Tests**
* Added validation to ensure integrations use compatible working-memory
scopes.
* Added coverage for direct, nested, resource-scoped, omitted, and
unrelated configuration cases.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
CopilotKit Examples
This directory contains 52 consolidated demo repositories showcasing CopilotKit integrations, canvas apps, and showcases.
Each example is a self-contained project. To get started:
GIT_LFS_SKIP_SMUDGE=1 git clone <repo-url>
cd examples/<category>/<name>
# Follow the example's own README for setup instructions
Note: The
v1/andv2/directories at the top level are legacy workspace examples from earlier CopilotKit releases and are not part of the consolidated demo set.
Integrations (20)
Framework integration starters demonstrating CopilotKit with various agent frameworks.
| Example | Description |
|---|---|
| langgraph-python | Starter template for building AI agents using LangGraph (Python) and CopilotKit |
| langgraph-js | Starter template for building AI agents using LangGraph (JS) with Turborepo monorepo |
| langgraph-fastapi | Starter template for building AI agents using LangGraph with FastAPI and Poetry |
| mastra | Starter template for building AI agents using Mastra and CopilotKit |
| crewai-flows | Starter template for building AI agents using CrewAI Flows (uv-based) |
| llamaindex | Starter template with a LlamaIndex investment analyst agent |
| pydantic-ai | Starter template with a PydanticAI investment analyst agent |
| ms-agent-framework-python | CopilotKit with Microsoft Agent Framework (Python/FastAPI, AG-UI protocol) |
| ms-agent-framework-dotnet | CopilotKit with Microsoft Agent Framework (.NET/C#, AG-UI protocol) |
| strands-python | Starter template with a Strands investment analyst agent |
| strands-typescript | Starter template using AWS Strands (TypeScript), AG-UI, and CopilotKit |
| mcp-apps | Integration of MCP Apps with CopilotKit using Three.js |
| adk | Starter template using Google ADK with an investment analyst agent |
| agent-spec | Starter for Agent Spec with A2UI-powered frontend tool rendering |
| a2a-a2ui | Starter for A2UI + A2A with a restaurant finder agent (Gemini/ADK) |
| agno | Starter template using Agno with an investment analyst agent |
| crewai-crews | Starter template for building AI agents using CrewAI Crews |
| a2a-middleware | Multi-agent starter with A2A Protocol and AG-UI Protocol (LangGraph + ADK) |
| claude-sdk-python | Starter template using the Claude Agent SDK (Python) and CopilotKit |
| claude-sdk-typescript | Starter template using the Claude Agent SDK (TypeScript) and CopilotKit |
Canvas (7)
AI-powered canvas applications with visual card interfaces, real-time state sync, and HITL workflows.
| Example | Description |
|---|---|
| langgraph-python | AG-UI canvas starter with LangGraph — interactive cards with real-time AI sync |
| llamaindex | AG-UI canvas starter with LlamaIndex — visual cards, multi-step planning, HITL |
| llamaindex-composio | Hackathon starter with LlamaIndex, CopilotKit, and Composio (Google Sheets integration) |
| pydantic-ai | AG-UI canvas starter with PydanticAI — visual cards, planning, HITL |
| mastra | AG-UI canvas starter with Mastra — interactive cards with real-time AI sync |
| gemini | Open Gemini Canvas — post generator and stack analyzer agents (Gemini + LangGraph) |
| mastra-pm | AG-UI + Mastra workshop — shared state, multiple clients, generative UI |
Showcases (25)
Full-featured demo applications highlighting CopilotKit capabilities in real-world scenarios.
| Example | Description |
|---|---|
| reskinnable-demo | Runtime-reskinnable demo — banking and airline skins over one shell, agent and all |
| presentation | PowerPoint-like web app built with CopilotKit |
| deep-agents | Deep research assistant with planning, memory/files, and generative UI (Tavily) |
| deep-agents-job-search | Job application assistant — resume parsing, skill extraction, DeepAgents orchestration |
| generative-ui | Generative UI for agentic apps — AG-UI protocol showcase |
| generative-ui-playground | Playground for static GenUI, MCP Apps, and A2UI generative UI types |
| grok-generative-ui | grok-4.6 searches X server-side, then composes the dashboard from real components |
| mcp-apps | MCP Apps demo — airline booking, hotel booking, investment simulator, kanban board |
| research-canvas | ANA (Agent Native Application) — research canvas with Tavily search and LangGraph |
| mcp-demo | Working Memory — MCP server-client integration for project management (Linear) |
| strands-file-analyzer | AI-powered document analysis with Strands Agents and Amazon Bedrock |
| microsoft-kanban | Kanban board demo with CopilotKit + Microsoft Agent Framework (.NET, AG-UI) |
| multi-page | Multi-page Remix app with CopilotKit |
| orca | Cisco CopilotKit demo — PR and repository analytics dashboard |
| pydantic-ai-todos | AI-powered todo board with PydanticAI (Todo, In-Progress, Done columns) |
| scene-creator | Scene creator with LangGraph + Gemini 3 — AI-generated characters and backgrounds |
| adk-dashboard | Generative canvas with Google ADK — metrics, charts, and real-time data |
| langgraph-js-support-agents | Multi-agent telecom support system with intent, lookup, reply, and escalation agents |
| multi-agent-canvas | Open Multi-Agent Canvas — manage multiple agents (travel, research, MCP) in one chat |
| chatkit-studio | Open ChatKit Studio — explore and build embeddable chat experiences |
| enterprise-brex | Enterprise banking demo with authorization, operations, and generative UI |
| a2a-travel | A2A + AG-UI multi-agent travel demo (LangGraph + Google ADK) |
| spreadsheet | AI-powered Excel-like spreadsheet web app |
| todo | Simple todo app built with CopilotKit |
| strands-crm | Enterprise sales CRM — dashboard, pipeline, products, quotes, reports & agentic canvas (TypeScript Strands + AG-UI) |