mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
2f2a703add
Fixes the demos a real-LLM audit found broken (aimock had masked them). Each
verified against real OpenAI (plain next dev / next build; turbopack dev is
broken on Windows — unrelated):
- shared-state-read / shared-state-read-write: seed agent state on [agent] deps
(not []). useAgent returns a provisional agent during /info sync; the real
runtime-synced agent swaps in as a new ref, so a []-deps seed effect never
re-ran and runAgent serialized empty state. NOTE: diverges from LGP's
byte-identical frontend — BIA's stateless in-process backend needs re-seeding;
LGP masks it via server-side state. Documented in PARITY_NOTES.
- set_notes -> STATE_DELTA add /notes in tanstack-factory convertStream (mirrors
set_steps), so shared-state-read-write notes render.
- declarative-gen-ui / a2ui-recovery: drop response_format:json_object (the
Responses-API openaiText ignores it and returned empty) — enforce JSON via
system prompt + stripJsonFences, like the byoc factories. Surfaces now paint.
- reasoning-custom / -default / tool-rendering-reasoning-chain: switch to the
Responses API with reasoning summaries (reasoning:{effort:high,summary:auto})
+ custom STEP_* -> REASONING_MESSAGE_* converter; real OpenAI chat-completions
never streams reasoning_content. Reasoning blocks now render.
- cvdiag/*: drop .js import extensions so /api/copilotkit resolves under dev
bundlers.
- PARITY_NOTES: document all fixes + that auth/voice 500 is next-dev-turbopack
only (verified working under next build/start in prod).
Built-in Agent (TanStack AI) Showcase
CopilotKit's BuiltInAgent in factory mode with TanStack AI as the LLM backend.
The agent runs in-process inside the Next.js API route — there is no separate agent server process to start (unlike the LangGraph TypeScript variant which spawns langgraph-cli on port 8123).
Quick Start
Prerequisites
- Node.js 18+
- An OpenAI API key
Setup
- Clone & install dependencies
npm install
- Set environment variables
Create a .env.local file from .env.example:
cp .env.example .env.local
Then fill in your OPENAI_API_KEY:
OPENAI_API_KEY=sk-...
NEXT_PUBLIC_COPILOTKIT_AGENT=default
- Start the dev server
npm run dev
Open http://localhost:3000 to see the demo index.
Build
npm run build
Architecture
- Agent Factory: See
src/lib/factory/tanstack-factory.tsfor theBuiltInAgentwiring and TanStack AI integration. - Tools: Defined in:
src/lib/factory/state-tools.ts— state management toolssrc/lib/factory/server-tools.ts— server-side toolssrc/lib/factory/subagent-tools.ts— sub-agent tools
- API Route:
src/app/api/copilotkit/[[...slug]]/route.tshandles the AG-UI protocol.
Next Steps
Phase 3+ will add individual demo pages under src/app/demos/.