This repository documents the process and challenges encountered while attempting to integrate CopilotKit v1.50 (Beta 2) into a standard Next.js application. It serves as a reproducible example for the issues observed during the upgrade.
The repository is organized into branches representing different stages and approaches to the integration:
-
main- Base Next.js application, bootstrapped via the official CLI.
-
01-copilot-stable- Successful implementation of CopilotKit stable version with LangChain, following the official quickstart guide.
-
02-copilot-1.50- Attempted upgrade to CopilotKit v1.50 beta.
- Outcome: Runtime failure with the error:
{ url: 'http://localhost:3000/api/copilotkit' } Invalid single-route payload.
-
03-copilot-1.50-with-langchain-1.x- Investigation into potential version conflicts by upgrading LangChain from v0.3.x (CopilotKit peer dependency) to v1.x.x.
- Outcome: Failed due to extensive type errors; approach abandoned.
-
04-copilot-1.50-with-openai-adapter- Isolated test using the bare-bones
OpenAIAdapterto rule out LangChain adapter specifics. - Outcome:
- Partial Success: Basic chat functionality and frontend tools (via
useCopilotAction) work. - Issues:
- The
copilotkitSuggestpayload (used for suggestion generation) triggers a console error:{ url: 'http://localhost:3000/api/copilotkit' } Invalid single-route payloadand returns a400 Bad RequestwithMissing method field. - Critical Failure: Adding
useCopilotReadablecauses the chat to stop working entirely, returning no response.
- The
- Partial Success: Basic chat functionality and frontend tools (via
- Isolated test using the bare-bones
According to the CopilotKit v1.50 Pre-Release Packet, the new version is intended to be fully backward compatible. However, our testing indicates a consistent regression affecting payload handling.
Specifically:
- The
OpenAIAdapterseems to expect amethodfield in the request body which is missing in thecopilotkitSuggestpayload generated by the frontend SDK. useCopilotReadablebreaks the chat loop completely.
Due to limited documentation for the beta release and a lack of similar reported issues, debugging has proven difficult. This repository aims to facilitate collaboration and resolution of these errors.