This solution has been AI generated
Your install of uuid likely changed the dependency graph and broke the CopilotKit runtime’s connection to the OpenAI Assistant. The logs show the backend route responds, but the runtime fails downstream with "Failed to retrieve assistant: fetch failed".
Why this happens
- Lockfile changes can hoist/downgrade transitive deps (e.g., Hono, @cfworker/json-schema), destabilizing
@copilotkitnext/runtime. - When using the OpenAI Assistant adapter, missing/invalid
OPENAI_API_KEYorOPENAI_ASSISTANT_IDafter reinstall causes "retrieve assistant" failures.
Steps to fix
- Revert lockfile changes and add
uuidwithout touching other deps
git checkout pnpm-lock.yaml
pnpm add uuid --save-exact
- Align CopilotKit package versions
pnpm list "@copilotkit*"
# Pin mixed versions to the same release, e.g.
pnpm add @copilotkit/runtime@-E @copilotkit/react-core@-E
- Verify environment variables
- Ensure
.env(or.env.local) still has:OPENAI_API_KEYOPENAI_ASSISTANT_ID(if using Assistants)
Restart dev server after updating.
- Clean install
rm -rf node_modules .next
pnpm store prune
pnpm install
pnpm dev
- Sanity-check the runtime
- Hit the info endpoint to confirm agents are registered:
curl -X POST http://localhost:3000/api/copilotkit/info -H "Content-Type: application/json" -d '{}'
It should return CopilotKit version and agent list. If it’s empty, the frontend can’t retrieve an assistant.
Optional: avoid the uuid package
If you only need IDs in this project, use CopilotKit’s utility:
import { randomUUID } from "@copilotkit/shared";
const id = randomUUID();
If the error persists after these steps, the issue is almost certainly an invalid/missing Assistant ID or OpenAI connectivity from the runtime; re-check the keys and that your runtime can reach OpenAI.