Repository navigation
fix(react-core): stop the compat CopilotKit wrapper pinning useSingleEndpoint - #6605
Merged
BenTaylorDev merged 2 commits intoAug 20, 2026
Merged
Conversation
…Endpoint
The `CopilotKit` wrapper is re-exported from `@copilotkit/react-core/v2`
(`v2/index.ts`), so it is the provider most integrations reach for. It pinned
`useSingleEndpoint={props.useSingleEndpoint ?? true}`, which overrode the core's
`"auto"` negotiation and forced single-route transport.
Every v2 handler defaults to `mode: "multi-route"`, so the pinned default made
the first browser request 404 while `GET /info` still returned 200 and looked
healthy. Four independent onboarding runs hit it and all four fixed it the same
way, with `useSingleEndpoint={false}`.
The prop already arrives through `v2Props`, so dropping the override lets it
stay `undefined` and resolve to `"auto"` — probe `GET /info`, fall back to the
single-route envelope — which works against either handler mode. An explicit
`useSingleEndpoint` still wins in both directions.
`CopilotChat.readinessGate.test.tsx` depended on the old default to avoid a REST
probe. Single-route transport is a precondition of that fixture rather than the
behaviour under test, so it now pins the flag explicitly and its comments are
corrected.
Refs OSS-888.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-telegram
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
Contributor
|
Size Change: -66 B (0%) Total Size: 1.34 MB 📦 View Changed
ℹ️ View Unchanged
|
…kills
The compat `<CopilotKit>` wrapper no longer pins `useSingleEndpoint` to `true`,
so every statement that it "defaults to single-route" or that a multi-route
backend "needs `{false}`" is now wrong. Code samples that pass `{false}`
explicitly stay valid — they pin what negotiation would find anyway — so this
corrects the explanations rather than the samples, keeping the pages true both
before and after the release.
The shipped `react-core` skill is the load-bearing one. `provider-setup.md`
mandated the wrapper, forbade `CopilotKitProvider` as "a subset of the
functionality", and never mentioned `useSingleEndpoint` across ~10 samples — so
an agent following it wrote the 404 configuration every time. It now documents
the transport and stops steering readers off the negotiating provider.
Also drops the false causal claim from the runtime's single-route-envelope
diagnostic (added in #6579), which named the wrapper's old default as the cause.
`skills/react-core/` is the generated mirror of `packages/react-core/skills/`,
synced with `pnpm sync:plugin-skills`.
Refs OSS-888.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
Production Digest-Pinning AuditAll 41 services digest-pinned. Run 2026-08-20 11:55:59 PDT — 0 finding(s). |
BenTaylorDev
marked this pull request as ready for review
August 20, 2026 19:06
BenTaylorDev
requested review from
jpr5,
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
August 20, 2026 19:06
tylerslaton
approved these changes
Aug 20, 2026
BenTaylorDev
deleted the
ben1/oss-888-v2-provider-handler-single-endpoint-default
branch
August 20, 2026 19:09
MikeRyanDev
added a commit
that referenced
this pull request
Aug 21, 2026
Moves docs and examples off the deprecated v1 runtime entrypoint, so a reader who follows a quickstart ends up with a runtime that can actually be probed (`GET /api/copilotkit/info`). **Stage 0** proves the target shape in a real running app; **Stage 1** propagates that proven code into the docs. 50 files. No file owned by #6517 or #6582 is touched (verified against the full ownership list). Stacks cleanly with #6618, which does the same for `showcase/integrations/**`. ## Stage 0 — `examples/shadcn`, proven live A textbook instance of the reported bug: a v1, POST-only route behind a `@copilotkit/react-core/v2` frontend. | | Before | After | | --- | --- | --- | | `GET /api/copilotkit` | **405** Method Not Allowed | 404 (correct: multi-route serves nothing at the bare basePath) | | `GET /api/copilotkit/info` | **404** — Next.js HTML 404, the path did not route at all | **200** | | `POST /api/copilotkit/agent/default/run` | n/a | **200**, chat turn renders in the UI | Exact `GET /api/copilotkit/info` body from the running app: ```json { "version": "1.61.2", "agents": { "default": { "name": "default", "description": "", "className": "BuiltInAgent", "capabilities": { "tools": { "supported": true, "clientProvided": true }, "transport": { "streaming": true }, "humanInTheLoop": { "interrupts": true } } } }, "audioFileTranscriptionEnabled": false, "mode": "sse", "threadEndpoints": { "list": true, "inspect": true, "mutations": false, "realtimeMetadata": false }, "a2uiEnabled": false, "openGenerativeUIEnabled": false, "telemetryDisabled": false } ``` (Captured before the `@copilotkit/*` bump in the same commit, hence `1.61.2`.) The model backend was aimock — `@copilotkit/aimock` 1.37.4, the same mock the `test / integration / docs` CI job uses — so the chat turn is real traffic through the migrated route with no live API key. ## Three findings that changed the shape of this work All three came from running the code rather than reading it, and all three affect every page Stage 1 touches. ### 1. The plan's canonical shape was deprecated, and that is where `hono` came from The prescribed snippet was `createCopilotEndpoint` + `handle` from `hono/vercel`. `createCopilotEndpoint` is a **deprecated alias** — this repo's own handler table in `docs/backend/runtime-endpoints.mdx` lists it under "Deprecated → use `createCopilotHonoHandler`". `createCopilotRuntimeHandler` serves the same multi-route mode (it is the default), returns a plain fetch handler, is not deprecated, and needs **no `hono` at all**: ```ts const handler = createCopilotRuntimeHandler({ runtime, basePath: "/api/copilotkit", }); export const GET = handler; export const POST = handler; ``` I first propagated the deprecated shape and then documented installing `hono` to make `hono/vercel` resolve under pnpm. Both are reverted in `720910833e`: `hono` was an artifact of the shape, not a requirement of the library. Verified by **deleting `node_modules/hono` outright**, not merely removing it from `package.json`, so a hoisted copy could not mask the result — `GET /info` → 200, `POST /agent/default/run` → 200, turn renders. No sidecar lists `hono` any more, so CI proves by construction that these snippets do not need it. ### 2. The multi-route runtime needs a frontend co-change, and the docs said otherwise Published `<CopilotKit>` still ships ```js useSingleEndpoint={props.useSingleEndpoint ?? true} ``` (verified in the `@copilotkit/react-core` 1.68.3 bundle), pinning the single-route transport. A multi-route runtime answers that envelope with **404 while `GET /info` still returns 200**, so the app looks connected. The runtime diagnoses it itself: > Received a single-route request envelope (`{ method: "..." }`) but this runtime is mounted in multi-route mode, so the request matched no route. If the frontend uses `<CopilotKit>` from `@copilotkit/react-core/v2`, pass `useSingleEndpoint={false}` — that provider defaults it to true. `backend/runtime-endpoints.mdx` — the authoritative page — said the opposite: that omitting the prop is safe on either provider because the client negotiates. True on `main` (#6605 removed the pin, merged today, unreleased) and **false in every published release**. `auth.mdx`, `custom-agent.mdx` and two quickstart callouts repeated it. All corrected: the pairing table now splits `<CopilotKit>` from `<CopilotKitProvider>` and says passing `{false}` is the forward-compatible choice — required now, harmless later. **This is a live docs defect independent of the migration.** So the v2 multi-route shape is *not* a drop-in for a v1 route: changing only the route file converts a working POST-only app into a broken one. ### 3. `showcase/shell`'s `@ts-ignore` is stale Its canonical route carries `// @ts-ignore — BuiltInAgent type mismatch with AbstractAgent, pending upstream fix`. `tsc --noEmit` passes without it on 1.68.3, so the docs snippets carry no suppression. Angular needs none of this: `provideCopilotKit` defaults its transport to `"auto"`. Those snippets are unchanged. ## The docs snippets now have a real CI gate The plan assumed there is no automated gate on `.mdx` snippets. There are two, and both mattered: - **`showcase/scripts/verify-shell-docs.ts`** asserts the *content* of titled fences, and for the two Claude SDK quickstarts it **requires** `ExperimentalEmptyAdapter` and `copilotRuntimeNextJSAppRouterEndpoint` — actively pinning those pages to v1. - **`scripts/doc-tests/{extract,run}.ts`** runs in CI (`test / integration / docs`): a fence tagged `doctest="component"` is extracted and typechecked with `tsc --noEmit` against real npm-installed deps. Exactly **one** fence in the whole docs tree opted in. **20 route snippets across 20 pages are now tagged `doctest="component"`** and typechecked in CI against real npm-installed packages. I had claimed the integration pages couldn't be doctested (path aliases, per-integration deps) — that was an assumption I never checked and it was wrong: 47 of 52 fences import nothing project-relative. Five harness defects blocked this and are fixed: - `extract.ts` wrote a fence title as a path without creating intermediate directories → ENOENT on any titled route fence. - `run.ts` derived the npm package name from the snippet directory; a catch-all leaf directory is literally `[[...slug]]`, which npm rejects. - `run.ts` looked for `doctest.json` only in the snippet's own directory while the sidecar is copied per page, so a nested snippet silently installed nothing and failed with "Cannot find module". - `extract.ts` found sidecars only in a page's own directory, which would have meant ~20 duplicated dependency lists; it now walks up to the docs root, so one shared list lives at `content/doctest.json`. - `run.ts` installed dependencies per snippet — **7:58** for 21 snippets against a 15-minute job timeout. Each dep set now installs **once** into `.doctest-output/.deps/<hash>` and is linked in: **0:45** cold. **Mutation-checked:** restoring the v1 import in a gated fence turns the run red (20 passed, 1 failed). My first attempt at this check was a silent no-op — the pattern missed because the fence is JSX-indented, and it "passed" misleadingly. The real check asserts the mutation reached the extracted snippet before trusting the result. `@ag-ui/*` has to be pinned to what the runtime expects (`@ag-ui/[email protected]`, `@ag-ui/[email protected]` for runtime 1.68.3). Unpinned, npm installs a newer `@ag-ui/client` and two `AbstractAgent` declarations collide: `separate declarations of a private property '_debug'`. **Seven fences are deliberately not gated**, un-tagged with reasons rather than left red: two are illustrative fences with placeholder identifiers (`myAgent`, `verifyJwt`), and five langgraph-family fences hit that same `_debug` collision via `@copilotkit/runtime/langgraph`, which pinning does not fix. **That one is a pre-existing package defect, not a migration regression** — I reconstructed the v1 form of the langgraph quickstart snippet verbatim from `origin/main`, typechecked it against identical deps, and it fails the same way. Those snippets have never typechecked against published packages. Worth filing; it is also what the ~220 `@ts-ignore` comments in `showcase/integrations` were papering over. ## A mistake worth recording A block regex scoped to the fence's opening indentation corrupted five quickstart pages: their fences open and close at *different* indentation, so the match ran past the closing backticks and re-indented the following `</Step>` / `</Tab>` into the code block. Reverted and redone with a line-oriented pass that never re-indents and re-emits the closing line verbatim. (A malformed `runner:` insertion on three a2ui pages was caught and redone the same way.) Every modified page is now checked structurally — fence-marker count plus every JSX structural line, indentation included, must be byte-identical to `HEAD`. That check found the corruption; a diff review had already missed it. ## Verification ``` pnpm tsx scripts/doc-tests/extract.ts -> 21 snippets pnpm tsx scripts/doc-tests/run.ts -> 21 passed, 0 failed (0:45 cold) vitest extract + verify-shell-docs -> 34 passed showcase/shell-docs: pnpm typecheck -> exit 0 showcase/shell-docs: pnpm lint -> exit 0 (pre-existing warnings only) showcase/shell-docs: pnpm build -> exit 0 examples/shadcn: tsc --noEmit / eslint / next build -> all clean, route ƒ /api/copilotkit/[[...slug]] structural audit -> every modified page, fence + JSX identical to HEAD ``` CI was green on the previous head (35 pass / 3 skip), including `doc-tests` and `format`. This validates that the pages build and that the one doctested snippet compiles. **It does not execute the remaining 32 fences.** Their correctness rests on Stage 0: the boilerplate they now contain is the text that was run in `examples/shadcn`, and each page's agent wiring is untouched. `LangGraphAgent` + v2 `CopilotRuntime` + `createCopilotRuntimeHandler` were typechecked together against published 1.68.3, since many pages depend on that combination. ## What could not be migrated, and why | Page | Why | | --- | --- | | `agentic-protocols/mcp.mdx` (self-hosting section) | Built on `createMCPClient`, which exists only in v1 (`packages/runtime/src/lib/runtime/copilot-runtime.ts`). v2's equivalent is `mcpApps`; converting is a content rewrite, not a mechanical migration. | | `snippets/self-hosting-copilot-runtime-create-endpoint.mdx` | The whole page is templated on v1 service adapters (`{{adapterImport}}`, `{{adapterSetup}}`). v2 has no service adapters. Needs a rewrite of the page's premise. | | Pages Router / NestJS tabs in the `self-hosting-*` snippets | v2 exports no equivalent factory — only `createCopilotRuntimeHandler` and the Hono/Express/Node handlers. The App Router tab on each page **is** migrated. | | Node HTTP / Express tabs | v2 equivalents exist (`createCopilotNodeHandler`, `createCopilotExpressHandler`) but I have not run them, and the rule here was not to write a snippet I have not run. | | `custom-agent.mdx` (both copies) | Three fences each still call `createCopilotEndpoint` as `export default copilotEndpoint` — the Hono-app deployment pattern, not a Next.js route. Predates this PR; the documented replacement is `createCopilotHonoHandler`, which I have not run. The two copies have also drifted from each other. | Deliberate v1 *prose* is left alone: `backend/copilot-runtime.mdx`'s v1→v2 mapping table and `auth.mdx`'s note that the v1 adapter does not forward `hooks` are correct as written. ## Other out-of-scope gaps, recorded so they can be filed - **Mastra docs name `CopilotKitIntelligence`** but never document constructor, project, thread, or user wiring. - **The A2UI fixed-schema guide** depends on showcase helpers not published as a package, so it cannot be followed standalone. - **`showcase/shared/starter-template` is not a runnable app** — no `package.json`, `next.config`, or `tsconfig`, so its route cannot be proved by running it. It was the plan's Stage 0 target on the grounds that "the CLI scaffolds from it"; nothing in CopilotKit `packages/**` or `Intelligence/apps/cli/src` references it, so that rationale does not hold. Its route is still v1 and still exports a hand-rolled `GET` that fetches the *agent's* `/health` and shadows `/info`. Queued behind a decision on where that status payload should live. - **`@copilotkit/cli@latest` (0.0.6) has no `verify` command**, so the `runtime_reachable: pass` evidence the plan asked for cannot be produced with the public CLI. The Intelligence CLI's `verify` is the one that probes `<runtimeUrl>/info` (`apps/cli/src/services/verify-probes.ts`), and the Stage 0 app satisfies that probe with a 200 — but the public-CLI artifact does not exist to paste. - **Two generators still emit v1** and will re-seed the problem: `showcase/scripts/create-integration/index.ts` and `examples/showcases/chatkit-studio/apps/playground/src/utils/codeGenerator.ts`. ## Corrected counts The plan's figures were all low, partly because they matched only double-quoted imports. Measured on `origin/main` at `43f1ef3039`: | Surface | Plan said | Actual | | --- | --- | --- | | v1 code files (`examples/` + `showcase/`, excl. `examples/v1/**` and `_legacy/`) | 244 | **352** | | `showcase/**` importing `@copilotkit/runtime` | 229 | **289** | | Docs files touching the v1 entrypoint | 44 (37 in scope) | **22 (12 in scope)** — the plan counted only `from "@copilotkit/runtime"`; the real set is smaller but includes single-quoted and factory-only files it missed | | Mixed v1-runtime + v2-frontend pages | 20 | **26** | | Files already on `createCopilotEndpoint` | 10 | **43 call sites** | ## Remaining - **Docs:** 52 route fences across 40 pages are on the v2 shape, **20 of them gated in CI**. The two Claude SDK quickstarts are migrated now that #6618 has landed. 7 pages still reference v1, every one for a reason in the tables above (several are deliberate prose). - **Code:** `showcase/integrations/**` (239 files) is handled in **#6618**. `examples/v1/**` (12 files) is deliberately v1 and never in scope. The rest of `examples/` is not in either PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs OSS-888.
The failure
A correctly assembled v2 integration 404s on its first browser request while every static check passes and
GET /inforeturns 200.packages/react-core/src/v2/index.ts:28re-exports the v1-compatCopilotKitwrapper, so it is the provider most integrations reach for. That wrapper pinned:which overrode the core's
"auto"negotiation and forced single-route transport. But every v2 handler defaults tomode: "multi-route"(endpoints/hono.ts:95;createCopilotEndpointis an alias at:90). Nothing serves the single-route envelope the client sends, so the runtime 404s while the provider looks connected.What this is not
The library defaults do not actually disagree.
CopilotKitProvider(the real v2 provider) leaves the flag undefined →"auto", which probesGET /infoand falls back to the single-route envelope (core/agent-registry.tsfetchRuntimeInfoAutoDetect) — it works against either handler mode. Only the compat wrapper defeated that.So this is one line of override, not a defaults mismatch needing a direction chosen.
Why four onboarding runs hit it, not one
The library bug alone doesn't explain a 100% failure rate. The shipped
react-coreskill does:packages/react-core/skills/react-core/references/provider-setup.md— bundled in the npm tarball (files: ["dist","skills"]) — mandated the compat wrapper, forbadeCopilotKitProvideras "a subset of the functionality", and mentioneduseSingleEndpointzero times across ~10 code samples. An agent following it wrote the 404 configuration every time.Meanwhile
skills/copilotkit-setup/SKILL.mdgot it right, so the two shipped skills contradicted each other and nothing gated either against the code.The change
Commit 1 — the library fix. The prop already arrives through
v2Props, so dropping the override lets it stayundefinedand inherit"auto". An explicituseSingleEndpointstill wins in both directions.Commit 2 — the docs and skills. Correcting the default made ~15 pages' explanations false. Code samples that pass
{false}stay valid (they pin what negotiation would find anyway), so this corrects the explanations rather than the samples — keeping every page true both before and after release. Includes dropping the now-false causal claim from the single-route-envelope diagnostic added in #6579.Compatibility
Safe for existing v1 apps. A v1 app on a single-route-only handler (
copilotRuntimeNextJSAppRouterEndpointand friends) now does oneGET /infothat 404s, then falls back to single-route and works. Cost is one extra request on connect.One edge case worth a reviewer's eye: if a deployment's
runtimeUrl+/inforeturns 200 from something that is not a multi-route CopilotKit runtime (a catch-all proxy serving HTML, say),"auto"would resolve torest. SettinguseSingleEndpointexplicitly remains the escape hatch.Conventional-commit note: this lands as
fix, but it does change a public default. Flag if you'd rather it carried a minor bump.Tests
copilotkit-transport-default.test.tsx— omitted →"auto",{true}→"single",{false}→"rest". Confirmed RED first (expected 'single' to be 'auto').CopilotChat.readinessGate.test.tsxdepended on the old default to avoid a REST probe. Single-route transport is a precondition of that fixture, not the behaviour under test, so it now pins the flag explicitly and its stale comments are corrected. Its coverage (readiness gate across the real SSE boundary) is unchanged.react-core1512 passed ·runtime2073 passed ·core668 passed.pnpm check:plugin-skillsin sync (skills/react-core/is the generated mirror).showcase/shell-docs's own vitest suite fails to load 35 files withCannot find package 'react/jsx-dev-runtime'— reproduced identically on unmodifiedorigin/main, so it is environmental in this checkout and unrelated. All 183 tests that do run pass.Not addressed here
Nothing gates a shipped skill against the code it documents, which is why
provider-setup.mdcould contradict both the library and the sibling skill indefinitely. Worth its own ticket.🤖 Generated with Claude Code