Repository navigation
fix(runtime): name useSingleEndpoint when a single-route envelope hits a multi-route runtime - #6579
Merged
BenTaylorDev merged 2 commits intoAug 20, 2026
Conversation
…s a multi-route runtime
The v1-compatible `<CopilotKit>` provider pins `useSingleEndpoint` to `true`,
so it POSTs `{ method: "info" }` at the base path. A multi-route runtime — the
default — matches no route for that path and answered a bare `{"error":"Not
found"}`, which is indistinguishable from a wrong `basePath` or an unmounted
handler. Two independent onboarding validation runs hit this on their first
attempt and had to guess the cause.
The runtime now recognises the envelope at the one point multi-route routing
gives up, and answers the 404 with a message naming the prop, plus a
`logger.warn` so it also lands in the dev server terminal. Status and shape are
unchanged for every other miss.
That message was reaching nobody: all four `/info` callers threw away the
response body and reported only the status. They now route through
`runtimeInfoError`, which folds a string `message` from the body into the
error — so any future server-side diagnosis reaches the developer too.
Docs: five pages paired a v2 multi-route handler with `<CopilotKit>` without
mentioning the prop. Their snippets now pass `useSingleEndpoint={false}` and
link to the provider/handler mapping. `backend/runtime-endpoints.mdx` already
documents the pairing and is untouched; `cookbook/arcade.mdx` deliberately uses
single-route mode and already explains it.
Closes OSS-882
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
BenTaylorDev
requested review from
jpr5,
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
August 19, 2026 22:42
Contributor
Production Digest-Pinning AuditAll 41 services digest-pinned. Run 2026-08-20 07:40:15 PDT — 0 finding(s). |
@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: +1.18 kB (+0.09%) Total Size: 1.34 MB 📦 View Changed
ℹ️ View Unchanged
|
…de pages
Two pages document both transport modes and carry a single "point your
frontend at it" snippet serving every front door on the page. Baking
`useSingleEndpoint={false}` into those snippets traded one silent mismatch for
its mirror image: correct for the multi-route majority, wrong for anyone who
followed the `mode: "single-route"` example.
Both now state the rule conditionally next to the snippet instead of asserting
one side of it. Pages with a single handler mode (auth, custom-agent) are
unambiguous and keep the prop inline.
Also pins the one path where the diagnostic could have cost more than it gives:
`clone()` throws once a before-request middleware has drained the body, so the
detector must return null and let the plain 404 stand rather than surfacing a
500. The guard existed; nothing held it in place.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
tylerslaton
approved these changes
Aug 20, 2026
MikeRyanDev
approved these changes
Aug 20, 2026
BenTaylorDev
deleted the
ben1/oss-882-single-endpoint-mismatch-diagnosis
branch
August 20, 2026 15:37
BenTaylorDev
added a commit
that referenced
this pull request
Aug 20, 2026
…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]>
BenTaylorDev
added a commit
that referenced
this pull request
Aug 20, 2026
…Endpoint (#6605) Refs [OSS-888](https://linear.app/copilotkit/issue/OSS-888). ## The failure A correctly assembled v2 integration 404s on its first browser request while every static check passes and `GET /info` returns 200. `packages/react-core/src/v2/index.ts:28` re-exports the **v1-compat** `CopilotKit` wrapper, so it is the provider most integrations reach for. That wrapper pinned: ```tsx useSingleEndpoint={props.useSingleEndpoint ?? true} ``` which overrode the core's `"auto"` negotiation and forced single-route transport. But **every** v2 handler defaults to `mode: "multi-route"` (`endpoints/hono.ts:95`; `createCopilotEndpoint` is 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 probes `GET /info` and falls back to the single-route envelope (`core/agent-registry.ts` `fetchRuntimeInfoAutoDetect`) — 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-core` skill does: `packages/react-core/skills/react-core/references/provider-setup.md` — bundled in the npm tarball (`files: ["dist","skills"]`) — **mandated** the compat wrapper, **forbade** `CopilotKitProvider` as "a subset of the functionality", and mentioned `useSingleEndpoint` **zero times** across ~10 code samples. An agent following it wrote the 404 configuration every time. Meanwhile `skills/copilotkit-setup/SKILL.md` got 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 stay `undefined` and inherit `"auto"`. An explicit `useSingleEndpoint` still 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 (`copilotRuntimeNextJSAppRouterEndpoint` and friends) now does one `GET /info` that 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` + `/info` returns 200 from something that is *not* a multi-route CopilotKit runtime (a catch-all proxy serving HTML, say), `"auto"` would resolve to `rest`. Setting `useSingleEndpoint` explicitly 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 - New `copilotkit-transport-default.test.tsx` — omitted → `"auto"`, `{true}` → `"single"`, `{false}` → `"rest"`. Confirmed RED first (`expected 'single' to be 'auto'`). - `CopilotChat.readinessGate.test.tsx` depended 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-core` 1512 passed · `runtime` 2073 passed · `core` 668 passed. - `pnpm check:plugin-skills` in sync (`skills/react-core/` is the generated mirror). `showcase/shell-docs`'s own vitest suite fails to load 35 files with `Cannot find package 'react/jsx-dev-runtime'` — reproduced identically on unmodified `origin/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.md` could contradict both the library and the sibling skill indefinitely. Worth its own ticket. 🤖 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.
Closes OSS-882.
The failure
The v1-compatible
<CopilotKit>provider pinsuseSingleEndpointtotrue(copilotkit.tsx:108), so its startup handshake POSTs{ method: "info" }at the base path. A multi-route runtime — the default — matches no route for that path and answered a bare{"error":"Not found"}, indistinguishable from a wrongbasePathor an unmounted handler.Two independent onboarding validation runs hit this on their first browser attempt and each had to guess the cause. Both were add-to-existing-app journeys; the greenfield one reached for
CopilotKitProviderand never saw it.What changed
The runtime says what happened.
detectSingleRouteEnveloperecognises a POST whose JSON body carries amethodthe single-route endpoint accepts, and the multi-route handler uses it at the one point routing gives up. The 404 now carries acodeand a message naming the prop, plus alogger.warnso it lands in the dev-server terminal too. Deliberately conservative — wrong verb, non-JSON, unknown method, or a JSON POST that isn't an envelope all stay ordinary 404s, unchanged in status and shape.The client stops discarding it. All four
/infocallers (two inagent-registry.ts, two inagent.ts) threw away the response body and reported only the status, so a server-side diagnosis reached nobody. They now go throughruntimeInfoError, which folds a stringmessagefrom the body into the thrown error. Any future server-side diagnosis reaches the developer for free.Docs. Five pages paired a v2 multi-route handler with
<CopilotKit>and never mentioned the prop. Rather than a warning under a snippet that is still wrong to copy, the snippets themselves now passuseSingleEndpoint={false}, with a short callout linking to the provider/handler mapping.Two pages were deliberately left alone:
backend/runtime-endpoints.mdxalready documents the pairing in full, andcookbook/arcade.mdxusesmode: "single-route"on purpose and already explains it.backend/copilot-runtime.mdxkeeps its snippet as-is — it pairs with the v1 endpoint, where the default is correct — and gains the caveat only on its "switch to v2 handlers" note.Option 3 in the issue (reconsidering the compat default) is not in this PR.
Testing
Both halves connect, end to end
Real
createCopilotRuntimeHandler+ realCopilotKitCoreconfigured the way the v1 wrapper configures it — no mocks on either side:The server-side
logger.warnfired in the same run, carrying{ url, path, method: 'info' }.Unit tests
packages/runtime—single-route-envelope-diagnostic.test.ts(2 positive, 5 control):packages/core—runtime-info-error-detail.test.ts(2 positive, 5 control):Mutation checks
Every new test was verified to fail when its mechanism is broken, in both directions.
Detector forced to
return null— the two positives die, the four controls hold:Detector forced to
return "info"— the controls die instead, proving they are not vacuous:runtimeInfoErrorwith the detail dropped, then with thetypeof message === "string"guard removed — each kills a different pair:Full suites, builds, docs
packages/corefull suiteTest Files 60 passed (60)/Tests 662 passed (662)packages/runtimefull suiteTest Files 142 passed (142)/Tests 2067 passed (2067)packages/coretsc --noEmitpackages/runtimetsdown416 files— build completeOKnx run-many -t test,publint,attwf94d1ab0Both suites are fully green. An earlier revision of this description reported 6
runtime failures as pre-existing on
main; they were not. They were artifactsof a worktree whose
node_moduleshad been assembled by hand, and a properpnpm installcleared all of them along with the inspector-metadata failuresfrom a stale
@copilotkit/shareddist.mainis clean.🤖 Generated with Claude Code