Repository navigation
fix: move docs and examples off the v1 runtime entrypoint - #6617
Merged
Merged
Conversation
Contributor
Production Digest-Pinning AuditAll 42 services digest-pinned. Run 2026-08-21 10:52:56 PDT — 0 finding(s). |
Contributor
|
Size Change: 0 B Total Size: 1.44 MB ℹ️ View Unchanged
|
BenTaylorDev
marked this pull request as ready for review
August 21, 2026 13:07
BenTaylorDev
requested review from
jpr5,
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
August 21, 2026 13:07
BenTaylorDev
added a commit
that referenced
this pull request
Aug 21, 2026
…ation (#6618) Retires the v1 runtime adapter from `showcase/integrations/`. After this, **no code under `showcase/integrations/` calls `copilotRuntimeNextJSAppRouterEndpoint`** — 239 routes across 20 integrations. This is the cheap path we discussed: single-route mode, which is a genuine drop-in. **No demo page changes, no route path changes, no `GET` exports, no new dependencies.** ## The shape ```ts const copilotHandler = createCopilotRuntimeHandler({ runtime, basePath: "/api/copilotkit-x", mode: "single-route", }); ... return await copilotHandler(req); ``` **Why single-route:** these demos' frontends are `<CopilotKit runtimeUrl="/api/copilotkit-x">` with no transport prop, and every released provider pins the single-route transport. So single-route mode is what the v1 adapter was already serving. Migrating to multi-route instead would have meant editing every demo page in lockstep, for no functional gain — nothing in the showcase probes `/info`. **Why `createCopilotRuntimeHandler`** rather than `createCopilotEndpointSingleRoute`: that helper is itself deprecated in favour of the `mode` option (per the deprecated-aliases table in `docs/backend/runtime-endpoints.mdx`), and the fetch handler needs no `hono` dependency and composes directly with the wrappers these routes already have. The statement is rewritten **in place**, inside whatever wrapper it already sat in, so `withForwardedHeaders`, the try/catch envelopes, `wrapStreamingResponse` and `withCvdiagBackend` are untouched. 75 of these routes construct the runtime inline in the call; rewriting in place preserves that per-request construction exactly as v1 did. No `runner` is added — it's optional and none of these routes passed one. 13 `copilotkit-auth/[[...slug]]` routes already use the v2 fetch handler and are left alone; they only name v1 in comments. ## Verified The shape was proved end-to-end **before** the rollout, in a real running app with an untouched provider (aimock as the model backend): `POST /api/copilotkit` → 200 twice, chat turn rendered in the browser. It also typechecks against the exact version these integrations pin (1.68.2). `mastra` is the integration installed and exercised locally — 19 routes, the `withCvdiagBackend` main route, and the only vitest suites that touch routes. Measured against `origin/main` **in the same tree**: | | baseline (`origin/main`) | after | | --- | --- | --- | | `tsc --noEmit` | errors in 10 files | errors in **9** | | `vitest run` | 2 files / 13 tests failed, 21 passed | 2 files / 13 tests failed, 21 passed | - **New type errors introduced: none.** - **Fixed:** `src/app/api/copilotkit-mcp-apps/route.ts`, whose `@ts-expect-error` was *already* unused on `main`. - **Test-neutral:** those 13 failures are pre-existing on `main` (mostly `extractXHeaders` dereferencing `req.headers` on a `{}` fake request). Structural audit over all 239 routes, re-run after the pre-commit formatter: none still imports the v1 root, calls the v1 adapter, references `ExperimentalEmptyAdapter` or `handleRequest` in code, or is missing `createCopilotRuntimeHandler` / `basePath` / `mode: "single-route"`. **CI has now built all 21 integrations green** — `showcase_build_check` Docker-builds each changed integration and `next build` typechecks inside it. That covers the ones I could not stand up locally, including the non-JS backends (`spring-ai`, `ms-agent-dotnet`, `ms-agent-python`, `ms-agent-harness-dotnet`, `langroid`, `strands`). Full run: 41 pass / 3 skip / 0 fail. To be precise about what each gate proves: CI proves these 21 apps still **build and typecheck**. It does not exercise a chat turn per integration — that came from the pre-rollout live proof of the shape itself, plus mastra's local test suite. ## Runtime verification on real cells Docker is not running on my machine, and `bin/showcase test --d6 --direct` requires it (`--direct` only swaps the in-process driver for the fleet control-plane; the containers are not optional). **So the sanctioned Iron Rule 4 probe has NOT been run** — that gap is real and a reviewer should weigh it. What I did instead was run a real integration directly. `showcase/integrations/mastra` on this branch, `npm run dev`, aimock as the model backend. Probing eight migrated routes with the exact envelope the released provider sends (`POST {basePath}` with `{"method":"info"}`) — all **200** with real runtime payloads: copilotkit-multimodal 200 agents: multimodal-demo copilotkit-mcp-apps 200 agents: headless-complete copilotkit-a2ui-fixed-schema 200 agents: a2ui-fixed-schema copilotkit-beautiful-chat 200 agents: beautiful-chat copilotkit-agent-config 200 agents: agent-config-demo copilotkit-ogui 200 agents: open-gen-ui copilotkit-declarative-gen-ui 200 agents: declarative-gen-ui copilotkit-background-agents 200 agents: background-agents Then three real demo cells driven in a browser, each rendering and completing a chat turn through its migrated route (two POSTs, both 200, assistant message rendered): /demos/beautiful-chat -> POST /api/copilotkit-beautiful-chat 200, 200 /demos/a2ui-fixed-schema -> POST /api/copilotkit-a2ui-fixed-schema 200, 200 /demos/multimodal -> POST /api/copilotkit-multimodal 200, 200 Deliberately spread across different route configs — plain, `a2ui`, and a dedicated vision-model route — rather than three variations of the same one. ### One route is 500, and it is pre-existing `POST /api/copilotkit` (mastra's main route) returns 500 in dev: `module-not-found` on `./schema.js` from `src/cvdiag/cvdiag-emitter.ts`. `schema.ts` **is** tracked and present — Turbopack in dev just does not resolve the ESM-style `.js` specifier to it. Proven pre-existing by restoring **only** that file to `origin/main` and re-probing: same 500 on the v1 code. Its Docker build passes, which is why CI is green. ### A mistake in my own verification, recorded My first pass at the above ran against the wrong branch — I was still on the docs branch, where these routes are v1, so the first six 200s I collected were the **v1** routes. Caught it, switched to this branch, and re-ran everything above against the migrated code. The accidental run was not wasted: it independently confirms the premise of this PR, that the v1 adapter and v2 single-route mode answer the same envelope the same way. ## Judgement call worth reviewing 27 `@ts-expect-error` directives guarded the **v1** `CopilotRuntime` agents type ("wraps `Record` in `MaybePromise<NonEmptyRecord<...>>`"). Under `/v2` that hole is gone, which makes the directive *unused* — a hard compile error. I demoted them to `@ts-ignore`, which compiles whether or not the mismatch survives in a given integration. The honest reason at the time: 19 of these apps can't be built locally, so I couldn't prove per-file which still need a suppression, and `@ts-ignore` is what 190 sibling files already use. Now that CI has built all 21 green, that constraint is gone — the ~220 now-stale suppressions (all of which cite a **v1** type hole that no longer applies) can be removed and verified by the same 21 builds. I've left them in place here to keep this PR mechanical and reviewable; say the word and I'll do it as a second pass. ## Two pre-existing problems found on the way - **`npm ci` fails in `showcase/integrations/mastra`**: `Missing: @types/[email protected] from lock file`. The Dockerfile uses `npm ci --legacy-peer-deps`, which *does* succeed, so the image still builds — but a plain `npm ci` doesn't. No manifest or lockfile is in this diff. - **`mastra`'s vitest suite is red on `main`** — 13 failures, as tabled above. ## What's left of the v1 entrypoint | Surface | Before | After | | --- | --- | --- | | `showcase/integrations/**` | 239 | **0** | | `examples/v1/**` | 12 | 12 (deliberately v1, never in scope) | | everything else in `examples/` | ~61 | ~61 (not in this PR) | Stacks cleanly with #6617 (docs) — no file overlap. It also **unblocks the two Claude SDK quickstart pages** I had to revert there: single-route keeps the starter file at the plain `route.ts` path, so those pages' prose claims and `verify-shell-docs.ts` starter-path checks stay valid, and only the fence body needs updating. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`examples/shadcn` paired a v1, POST-only runtime route with a
`@copilotkit/react-core/v2` frontend. `GET /api/copilotkit` answered 405 and
`GET /api/copilotkit/info` did not route at all (404), so nothing could probe
the runtime.
Convert the route to the v2 multi-route shape at a catch-all path, exporting
both verbs:
app/api/copilotkit/[[...slug]]/route.ts
createCopilotEndpoint({ runtime, basePath: "/api/copilotkit" })
export const GET = handle(app)
export const POST = handle(app)
Two co-changes this shape requires, both found by running the app rather than
by reading it:
- `hono` becomes a direct dependency. It is a dependency of
`@copilotkit/runtime`, not a peer, so under pnpm's strict layout
`import { handle } from "hono/vercel"` does not resolve from the app
without declaring it.
- the provider must pass `useSingleEndpoint={false}`. The published
`<CopilotKit>` from `@copilotkit/react-core/v2` defaults to the
single-route transport, which posts a single-route envelope to the bare
basePath; a multi-route runtime answers that with 404. The runtime says so
itself in the error body.
`@copilotkit/*` moves 1.61.2 -> 1.68.3 so the app runs the versions a reader
installing today would get.
Verified live (aimock on :4010 as the model backend):
GET /api/copilotkit/info -> 200, runtime /info payload
POST /api/copilotkit/agent/default/run -> 200, chat turn renders
before: GET /api/copilotkit -> 405, GET /api/copilotkit/info -> 404
tsc --noEmit, eslint, next build all clean
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`snippets/copilot-runtime.mdx` calls itself "the recommended way to use
CopilotKit" and taught the v1 plain-POST route. A reader following it got an
endpoint that answers 405 on `GET /api/copilotkit` and does not route
`GET /api/copilotkit/info` at all, so nothing could discover the runtime.
The route fence is now the shape proved in `examples/shadcn`: catch-all path,
`createCopilotEndpoint`, a runner, and both verbs exported. The three other
fences on the page that were titled with the plain route path are retitled to
the catch-all path, so no snippet claims a path its body contradicts.
Also documents the two things the shape actually requires, both of which were
found by running it:
- `npm install @copilotkit/runtime hono` — `hono` is a dependency of the
runtime rather than a peer, so `hono/vercel` resolves under npm's flat
layout but not under pnpm.
- `useSingleEndpoint={false}` on `<CopilotKit>`. The provider defaults it to
`true` (single-route transport), which posts to the bare `runtimeUrl`; a
multi-route runtime answers that with 404. The Angular provider defaults its
transport to `"auto"` and needs no equivalent change, so that snippet is
unchanged.
## The snippet is now gated in CI
`scripts/doc-tests` already extracts fences tagged `doctest=` and, for
`component`, runs `tsc --noEmit` against real npm-installed dependencies — but
it could not handle a fence whose title is a path, which is exactly what a
Next.js route handler's title is. Two defects blocked it, both fixed here:
- `extract.ts` wrote the title as a path without creating intermediate
directories, so a titled route fence died on ENOENT.
- `run.ts` derived the npm package name from the snippet directory, and a
catch-all leaf directory is literally `[[...slug]]`, which npm rejects as an
invalid name. It also looked for `doctest.json` only in the snippet's own
directory, while the sidecar is copied once per page — so a nested snippet
silently installed no dependencies and failed with "Cannot find module".
With those fixed, the canonical route snippet is tagged `doctest="component"`
and typechecked in CI against the published `@copilotkit/runtime` 1.68.3 and
`hono`. This is the gate the docs did not have: snippet correctness no longer
rests on review alone.
Verified:
pnpm tsx scripts/doc-tests/extract.ts -> 2 snippets extracted
pnpm tsx scripts/doc-tests/run.ts -> 2 passed, 0 failed
mutation check: restoring the v1 import in the fence turns the run red
(1 passed, 1 failed), so the gate fails on the regression it exists to catch
vitest scripts/doc-tests/__tests__/extract.test.ts -> 10 passed
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Migrates the Next.js App Router runtime fences across the docs from the v1
entrypoint to the v2 multi-route shape proved in `examples/shadcn`: catch-all
path, `createCopilotEndpoint`, a runner, and both verbs exported. 38 fences
across 33 pages.
Only the boilerplate is rewritten. Each page's agent wiring — `MastraAgent`,
`LangGraphAgent`, `HttpAgent`, `BuiltInAgent`, middleware `.use(...)` calls —
is left byte-identical, because that part is not what was broken.
Three co-changes travel with every migrated page, since the shape does not work
without them:
- `hono` added to the page's install command (20 lines). It is a dependency of
`@copilotkit/runtime`, not a peer, so `hono/vercel` resolves under npm's flat
layout but not under pnpm.
- `useSingleEndpoint={false}` on `<CopilotKit>` (27 provider tags). The
provider defaults to the single-route transport, which posts to the bare
`runtimeUrl`; a multi-route runtime answers with 404. Only tags carrying a
`runtimeUrl` are touched — a provider using `agents__unsafe_dev_only` has no
runtime to match. Angular's `provideCopilotKit` defaults its transport to
`"auto"` and needs no equivalent, so those snippets are unchanged.
- fence titles retitled to the catch-all path, plus the prose that introduces
them, so no snippet claims a path its body contradicts.
`LangGraphAgent` moves from the v1 root entrypoint to
`@copilotkit/runtime/langgraph` on one page. Both spellings resolve, but the
subpath is the one that survives the v1 entrypoint; verified by typechecking
`LangGraphAgent` + v2 `CopilotRuntime` + `createCopilotEndpoint` together
against the published 1.68.3.
## Two mistakes worth recording, since both were caught by a check rather than by reading
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>` boundary into the code block. The five pages were reverted
and redone with a line-oriented pass that never re-indents anything and
re-emits the original closing line verbatim.
Every modified page is now checked structurally — fence-marker count and the
full set of JSX structural lines, indentation included, must be identical to
`HEAD`. All 33 pass. That check is what found the corruption; a diff review had
already missed it on the first pass.
## Verified
pnpm tsx scripts/doc-tests/extract.ts -> 2 snippets
pnpm tsx scripts/doc-tests/run.ts -> 2 passed, 0 failed
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
structural audit: 33/33 pages, fence + JSX structure identical to HEAD
Note this validates that the pages still build and that the one doctested
snippet compiles. It does not execute the other 37 fences. Their correctness
rests on Stage 0: the boilerplate they now contain is the text that was run in
`examples/shadcn`, and their agent wiring is untouched.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Finishes the tractable remainder of the v1 -> v2 runtime sweep, and fixes a
docs claim that the previous commit's `useSingleEndpoint={false}` edits exposed
as wrong.
## The pairing guidance described unreleased behaviour
`backend/runtime-endpoints.mdx` is the authoritative page for provider/handler
pairs, and it said omitting `useSingleEndpoint` is safe on either provider
because the client negotiates from `/info` — with `auth.mdx` and two quickstart
callouts repeating it. That is true on `main` and false in every published
release: the compat `<CopilotKit>` wrapper still ships
useSingleEndpoint={props.useSingleEndpoint ?? true}
(verified in the published `@copilotkit/react-core` 1.68.3 bundle), so omitting
the prop selects the single-route transport and 404s against a multi-route
Runtime. The Runtime's own error body says so. `<CopilotKitProvider>` does
negotiate; only the wrapper pins — and every docs snippet uses the wrapper.
So the pairing table now splits the two providers instead of grouping them,
states that the pin exists in released versions and is removed on `main`, and
says plainly that passing `{false}` is the forward-compatible choice. The
"pinning the wrong mode 404s silently" warning now covers omitting the prop on
`<CopilotKit>`, which is the same failure by a different route. Same correction
applied to `auth.mdx` and to the two "Which provider goes with which handler?"
callouts, which additionally still named `copilotRuntimeNextJSAppRouterEndpoint`
as the route above them after that route became `createCopilotEndpoint`.
## Remaining migrations
- `self-hosting-remote-endpoints.mdx` — three LangGraph fragments moved to
`@copilotkit/runtime/v2` for `CopilotRuntime` and
`@copilotkit/runtime/langgraph` for the agents, splitting what was a single
v1 root import.
- `copilot-runtime.mdx` — the transport callout rewritten to match the
authoritative page and link to it, rather than asserting the default itself.
## Verified
pnpm tsx scripts/doc-tests/run.ts -> 2 passed, 0 failed
showcase/shell-docs: pnpm typecheck -> exit 0
showcase/shell-docs: pnpm build -> exit 0
structural audit: 6/6 mdx files, fence + JSX structure identical to HEAD
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Seven fences already imported from `@copilotkit/runtime/v2` but were still
titled `app/api/copilotkit/route.ts`. That is the same title/body mismatch this
sweep exists to fix, seen from the other side: a reader follows the title,
creates a plain route file for a runtime that needs the catch-all path, and gets
no `/info`.
Titles only — no bodies changed.
Two categories are deliberately left on the plain path, because there it is
correct:
- fences mentioning `createCopilotEndpointSingleRoute`. Single-route mode is
served from a plain `route.ts` and is POST-only by design; retitling one would
destroy what it demonstrates.
- fences still on the v1 entrypoint. Those are separate migrations, blocked for
the reasons recorded in the PR description.
Verified:
pnpm tsx scripts/doc-tests/run.ts -> 2 passed, 0 failed
showcase/shell-docs: pnpm build -> exit 0
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The earlier commits in this PR taught `createCopilotEndpoint` paired with
`handle` from `hono/vercel`, and added `hono` to 20 install commands with a
callout explaining why readers must install it. Both were wrong, and the second
was a consequence of the first.
`createCopilotEndpoint` is a **deprecated alias**. This repo's own handler table
says so — `docs/backend/runtime-endpoints.mdx`:
| Deprecated | Use instead |
| `createCopilotEndpoint` | `createCopilotHonoHandler` |
| `createCopilotEndpointSingleRoute` | ... with mode: "single-route" |
`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**. So the route collapses to:
const handler = createCopilotRuntimeHandler({
runtime,
basePath: "/api/copilotkit",
});
export const GET = handler;
export const POST = handler;
`hono` was therefore an artifact of the shape, not a requirement of the library.
The install lines and the callout are reverted; nothing tells readers to install
it any more.
## Verified with hono deleted, not merely absent from package.json
`examples/shadcn` converted to this shape, `hono` removed from its
`package.json`, and `node_modules/hono` deleted outright so a hoisted copy could
not mask the result:
GET /api/copilotkit/info -> 200
POST /api/copilotkit/agent/default/run -> 200, chat turn rendered
tsc --noEmit / eslint / next build -> clean
next build route -> ƒ /api/copilotkit/[[...slug]]
The doctest sidecar drops `hono` too, so the CI gate now typechecks the
canonical snippet against `@copilotkit/runtime` alone — proof by construction
that the snippet needs nothing else.
pnpm tsx scripts/doc-tests/run.ts -> 2 passed, 0 failed
showcase/shell-docs: typecheck -> exit 0
showcase/shell-docs: build -> exit 0
structural audit: 31/31 mdx files, fence + JSX identical to HEAD
## Also corrected
`docs/backend/custom-agent.mdx` repeated the same incorrect transport claim the
earlier commit fixed in four other places ("Both `<CopilotKit>` and
`<CopilotKitProvider>` negotiate the transport when the prop is omitted").
Corrected to match released behaviour.
## Left alone deliberately
`snippets/shared/backend/custom-agent.mdx` and `docs/backend/custom-agent.mdx`
still call `createCopilotEndpoint` in three fences each, as
`export default copilotEndpoint` — the Hono-app deployment pattern rather than a
Next.js route handler. That predates this PR, the documented replacement is
`createCopilotHonoHandler`, and I have not run that shape. Recorded as follow-up
rather than guessed at. (The two files have also drifted from each other, which
is a separate problem.)
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…arts Two things this PR was missing, both now closed. ## The Claude SDK quickstarts are unblocked #6618 put `showcase/integrations/claude-sdk-{python,typescript}` on `createCopilotRuntimeHandler` with `mode: "single-route"`, at the **plain** `route.ts` path. That dissolves the coupling that forced these two pages to be reverted earlier: `verify-shell-docs.ts` asserts each page claims a starter file at `src/app/api/copilotkit/route.ts` AND that the file exists in the extracted starter. Single-route keeps that path, so the prose claims and `requiredStarterFiles` are unchanged — only the fence bodies move to v2. The two content assertions that pinned those pages to v1 (`ExperimentalEmptyAdapter`, `copilotRuntimeNextJSAppRouterEndpoint`) now require `createCopilotRuntimeHandler`, the `/v2` entrypoint, `mode: "single-route"` and a `POST` export. Mutation-checked: flipping the fixture to `mode: "multi-route"` fails with `app/api/copilotkit/route.ts missing single-route mode`. ## Snippet gating: 1 -> 20 route fences I previously claimed the integration pages could not be doctested because of path aliases and per-integration deps. **That was an assumption I never checked, and it was wrong.** Of the 52 migrated route fences, 47 import nothing project-relative; 36 are complete, self-standing routes. 27 pages were eligible, 20 now hold a gated fence — each extracted and typechecked by `tsc --noEmit` against real npm-installed packages in CI. One fence per (page, title): `extract.ts` concatenates tagged blocks sharing a title, so a second complete route on the same page would collide. Mutation-checked on `snippets/integrations/langsmith/index.mdx`: restoring the v1 import in the gated fence turns the run red (20 passed, 1 failed). My first attempt at this check was a 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. ### Harness changes this needed - `extract.ts` now finds the nearest `doctest.json` by walking up to the docs root, instead of looking only in the page's own directory. Otherwise gating 20 pages means ~20 duplicated dependency lists that then drift. A shared list lives at `content/doctest.json`; `docs/integrations/langgraph/` keeps its own (Python deps) and now also carries the TS deps its page needs. - `run.ts` installs each dependency set **once**, into `.doctest-output/.deps/<hash>`, and links it into every snippet sharing that set. Per-snippet installs took **7:58** for 21 snippets, uncomfortably close to the job's 15-minute timeout; shared installs take **0:45** cold. Different dep sets still get separate stores, so this is a dedupe, not a merge. ### `@ag-ui/*` versions have to be pinned to what the runtime expects Unpinned, the gated fences failed with `HttpAgent is not assignable to AbstractAgent — separate declarations of a private property '_debug'`: npm installs a newer `@ag-ui/client` than `@copilotkit/runtime` depends on, so two `AbstractAgent` declarations collide. The sidecar pins `@ag-ui/[email protected]` and `@ag-ui/[email protected]` to match `@copilotkit/[email protected]`. ## Seven fences are deliberately NOT gated Un-tagged with the reason, rather than left failing or quietly dropped: - `docs/auth.mdx`, `docs/premium/connect-your-runtime.mdx` — illustrative fences referencing placeholders (`myAgent`, `verifyJwt`) that cannot compile standalone by design. - the four langgraph-family pages and `snippets/self-hosting-copilot-runtime-langgraph-endpoint.mdx` — these hit `LangGraphAgent is not assignable to AbstractAgent — separate declarations of a private property '_debug'`, which pinning does not fix. **That last one is a real pre-existing defect, not a migration regression.** I reconstructed the v1 form of the langgraph quickstart snippet verbatim from `origin/main` and typechecked it against the identical installed dependencies: it fails with the same error. So these snippets have never typechecked against published packages — worth filing separately. It is also what the ~220 `@ts-ignore` comments across `showcase/integrations` were papering over. ## Verified doc-tests (cold, no cache) -> 21 passed, 0 failed in 0:45 mutation check (real, verified) -> 20 passed, 1 failed vitest extract + verify-shell-docs -> 34 passed showcase/shell-docs typecheck -> exit 0 showcase/shell-docs build -> exit 0 structural audit -> 21/21 pages, fence + JSX identical to HEAD Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
BenTaylorDev
force-pushed
the
ben1/v2-runtime-migration
branch
from
August 21, 2026 14:28
7209108 to
5ca110e
Compare
@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: |
…tion # Conflicts: # showcase/shell-docs/src/content/snippets/shared/generative-ui/a2ui.mdx
BenTaylorDev
requested review from
rainerhahnekamp and
wolfmanfx
as code owners
August 21, 2026 17:52
MikeRyanDev
approved these changes
Aug 21, 2026
BenTaylorDev
added a commit
that referenced
this pull request
Sep 14, 2026
## Problem
`LangGraphAgent` exported from the `@copilotkit/runtime` **root** is a
deprecation stub whose constructor throws:
```
Error: LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
at new LangGraphAgent (.../dist/lib/index.mjs:25:9)
```
The throw is in the constructor, not at import time, so a file that only
imports the symbol still loads.
Both canvas examples float their runtime pin, so a fresh install
resolves the latest 1.x (1.71.1 today) and gets the stub:
| Example | Pin | Imports from root | Constructs | Effect |
|---|---|---|---|---|
| `examples/canvas/langgraph-python` | `^1.10.4` | yes | yes |
`/api/copilotkit` throws at module load — the example does not boot |
| `examples/canvas/gemini` | `^1.9.3` | yes | no | dead import of a
throw-only stub |
## Fix
- `canvas/langgraph-python`: import `LangGraphAgent` from
`@copilotkit/runtime/langgraph`.
- `canvas/gemini`: drop the unused import.
No behavior change beyond the import path. Two lines.
## Testing
A structural scan of the repo for a **root** import of
`LangGraphAgent`/`LangGraphHttpAgent` that is also constructed. Before
the change, three files matched; after it, none outside dead content:
```
examples/canvas/gemini/.../route.ts: dead-import LangGraphAgent
examples/canvas/langgraph-python/.../route.ts: CONSTRUCTS LangGraphAgent
showcase/shell-docs/.../self-hosting-copilot-runtime-langgraph-endpoint.mdx: CONSTRUCTS LangGraphAgent
```
The third hit is deliberately **not** in this PR — that snippet file is
referenced by nothing in the repo (its siblings are imported as
`@/snippets/<name>.mdx`; this one has no importer), so it is orphaned
content and a separate call. Flagged below.
Before/after against the version the example's own `package.json`
resolves to (`@copilotkit/[email protected]`), replaying the example's
exact route construction:
```
########## BEFORE (root import, as on main) ##########
Error: LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
########## AFTER (this PR's import) ##########
after: OK — agent constructed, handleRequest is function
```
End-to-end, the fixed import shape was driven against a live LangGraph
deployment (langgraph 1.2.11 + langchain 1.4.0, `create_agent`),
`@copilotkit/[email protected]`, agent registered exactly as the example
registers it. A full turn streams and completes:
```
1 "type":"RUN_STARTED"
1 "type":"TOOL_CALL_START"
1 "type":"TOOL_CALL_RESULT"
1 "type":"MESSAGES_SNAPSHOT"
1 "type":"RUN_FINISHED"
```
No `RUN_ERROR`. `gemini` has no other reference to `LangGraphAgent`, so
removing the import is inert. `oxfmt --check` passes on both files.
Commit hooks were bypassed (this worktree has no `node_modules`, so
lefthook cannot run); `oxfmt --check` was run manually against the
repo's pinned binary instead.
## Follow-up, not in this PR
`showcase/shell-docs/src/content/snippets/self-hosting-copilot-runtime-langgraph-endpoint.mdx`
has four tabs (Pages Router, Express, Node HTTP, NestJS) still showing
the throwing root import — #6617 converted only the first tab. Nothing
imports the file, so it ships to no reader today. It wants a decision
(wire it up, or delete it) rather than a silent one-line patch.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
BenTaylorDev
added a commit
that referenced
this pull request
Sep 14, 2026
Follow-up to #7120, which fixed the same defect in the two canvas examples. ## What this deletes `showcase/shell-docs/src/content/snippets/self-hosting-copilot-runtime-langgraph-endpoint.mdx`. It is dead content, and it is stale content. **Dead.** shell-docs reaches a snippet by exactly two routes, and the file is on neither: 1. An MDX import, `@/snippets/<path>` — resolved by `inlineSnippets`. No file in the repo imports this one. 2. A stub-name entry in `mdx-registry.tsx` / `docs-render.tsx` — read back by `mdx-registry-loader.tsx` through a mapped relative path. This file has no entry; its two live siblings, `self-hosting-copilot-runtime-create-endpoint.mdx` and `self-hosting-copilot-runtime-configure-copilotkit-provider.mdx`, do. Nothing enumerates the snippets directory — no glob, no `readdirSync` over it — so an unreferenced file there is reachable by no code path. A raw repo-wide grep for the basename also returns nothing. Its importer was the retired docs app, removed in 33a7948 (2026-06-18). The snippet was left behind. **Stale.** Four of its five tabs (Pages Router, Express, Node HTTP, NestJS) still import `LangGraphAgent` from the `@copilotkit/runtime` root, which is a deprecation stub whose constructor throws on any version >= 1.7x: ``` Error: LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead ``` #6617 converted only the App Router tab. So the file is simultaneously invisible to readers and wrong. ## Why delete rather than patch The live LangGraph quickstart already documents the endpoint with the correct import (`showcase/shell-docs/src/content/docs/integrations/langgraph/quickstart.mdx:371`). Patching four tabs of a file that ships to nobody adds a maintenance surface without adding a reader. ## Testing Deletion only — no code changes. Verified by four independent lenses, each of which came back empty for this file: | Lens | Result | |---|---| | MDX imports of `@/snippets/self-hosting-copilot-runtime-langgraph-endpoint.mdx` | none | | `mdx-registry.tsx` / `docs-render.tsx` stub maps | absent | | Directory enumeration of `src/content/snippets` | no such mechanism exists | | Repo-wide `grep -F` for the basename | none | I did not build shell-docs locally; the branch's shell-docs CI jobs are the check that matters for a content deletion, and a reference that all four lenses missed would surface there. ## Note, not addressed here While scoping this I ran two different orphan sweeps over all 98 snippets and they disagreed sharply (19 vs 42 candidates) — path-matching over-reports because it misses registry entries, basename-matching under-reports because distinct files share a basename. A real answer needs a resolver that follows both mechanisms. That is worth doing, and it is not this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Documentation** - Removed the self-hosting guide for configuring Copilot Runtime LangGraph endpoints. - The guide previously covered setup examples for Next.js, Node.js, Express, and NestJS. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
NathanTarbert
pushed a commit
to vvlrff/CopilotKit
that referenced
this pull request
Sep 14, 2026
`snippets/self-hosting-copilot-runtime-langgraph-endpoint.mdx` reaches no reader. It is referenced by neither of the two mechanisms shell-docs uses: no MDX file imports `@/snippets/self-hosting-copilot-runtime-langgraph-endpoint.mdx`, and it appears in neither `mdx-registry.tsx` nor `docs-render.tsx`. Its importer was the retired docs app, deleted in 33a7948. It is also stale. Four of its five tabs still show `LangGraphAgent` imported from the `@copilotkit/runtime` root, whose constructor throws on any version >= 1.7x; CopilotKit#6617 converted only the App Router tab. The live LangGraph quickstart already documents the correct `@copilotkit/runtime/langgraph` import, so nothing is lost by removing the file rather than patching content that ships to nobody. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
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 liveA textbook instance of the reported bug: a v1, POST-only route behind a
@copilotkit/react-core/v2frontend.GET /api/copilotkitGET /api/copilotkit/infoPOST /api/copilotkit/agent/default/runExact
GET /api/copilotkit/infobody from the running app:{ "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, hence1.61.2.) The model backend was aimock —@copilotkit/aimock1.37.4, the same mock thetest / integration / docsCI 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
honocame fromThe prescribed snippet was
createCopilotEndpoint+handlefromhono/vercel.createCopilotEndpointis a deprecated alias — this repo's own handler table indocs/backend/runtime-endpoints.mdxlists it under "Deprecated → usecreateCopilotHonoHandler".createCopilotRuntimeHandlerserves the same multi-route mode (it is the default), returns a plain fetch handler, is not deprecated, and needs nohonoat all:I first propagated the deprecated shape and then documented installing
honoto makehono/vercelresolve under pnpm. Both are reverted in720910833e:honowas an artifact of the shape, not a requirement of the library. Verified by deletingnode_modules/honooutright, not merely removing it frompackage.json, so a hoisted copy could not mask the result —GET /info→ 200,POST /agent/default/run→ 200, turn renders. No sidecar listshonoany 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(verified in the
@copilotkit/react-core1.68.3 bundle), pinning the single-route transport. A multi-route runtime answers that envelope with 404 whileGET /infostill returns 200, so the app looks connected. The runtime diagnoses it itself:backend/runtime-endpoints.mdx— the authoritative page — said the opposite: that omitting the prop is safe on either provider because the client negotiates. True onmain(#6605 removed the pin, merged today, unreleased) and false in every published release.auth.mdx,custom-agent.mdxand 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-ignoreis staleIts canonical route carries
// @ts-ignore — BuiltInAgent type mismatch with AbstractAgent, pending upstream fix.tsc --noEmitpasses without it on 1.68.3, so the docs snippets carry no suppression.Angular needs none of this:
provideCopilotKitdefaults 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
.mdxsnippets. There are two, and both mattered:showcase/scripts/verify-shell-docs.tsasserts the content of titled fences, and for the two Claude SDK quickstarts it requiresExperimentalEmptyAdapterandcopilotRuntimeNextJSAppRouterEndpoint— actively pinning those pages to v1.scripts/doc-tests/{extract,run}.tsruns in CI (test / integration / docs): a fence taggeddoctest="component"is extracted and typechecked withtsc --noEmitagainst 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.tswrote a fence title as a path without creating intermediate directories → ENOENT on any titled route fence.run.tsderived the npm package name from the snippet directory; a catch-all leaf directory is literally[[...slug]], which npm rejects.run.tslooked fordoctest.jsononly 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.tsfound 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 atcontent/doctest.json.run.tsinstalled 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/clientand twoAbstractAgentdeclarations 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_debugcollision 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 fromorigin/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-ignorecomments inshowcase/integrationswere 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 malformedrunner: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
CI was green on the previous head (35 pass / 3 skip), including
doc-testsandformat.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+ v2CopilotRuntime+createCopilotRuntimeHandlerwere typechecked together against published 1.68.3, since many pages depend on that combination.What could not be migrated, and why
agentic-protocols/mcp.mdx(self-hosting section)createMCPClient, which exists only in v1 (packages/runtime/src/lib/runtime/copilot-runtime.ts). v2's equivalent ismcpApps; converting is a content rewrite, not a mechanical migration.snippets/self-hosting-copilot-runtime-create-endpoint.mdx{{adapterImport}},{{adapterSetup}}). v2 has no service adapters. Needs a rewrite of the page's premise.self-hosting-*snippetscreateCopilotRuntimeHandlerand the Hono/Express/Node handlers. The App Router tab on each page is migrated.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)createCopilotEndpointasexport default copilotEndpoint— the Hono-app deployment pattern, not a Next.js route. Predates this PR; the documented replacement iscreateCopilotHonoHandler, 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 andauth.mdx's note that the v1 adapter does not forwardhooksare correct as written.Other out-of-scope gaps, recorded so they can be filed
CopilotKitIntelligencebut never document constructor, project, thread, or user wiring.showcase/shared/starter-templateis not a runnable app — nopackage.json,next.config, ortsconfig, 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 CopilotKitpackages/**orIntelligence/apps/cli/srcreferences it, so that rationale does not hold. Its route is still v1 and still exports a hand-rolledGETthat fetches the agent's/healthand shadows/info. Queued behind a decision on where that status payload should live.@copilotkit/cli@latest(0.0.6) has noverifycommand, so theruntime_reachable: passevidence the plan asked for cannot be produced with the public CLI. The Intelligence CLI'sverifyis 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.showcase/scripts/create-integration/index.tsandexamples/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/mainat43f1ef3039:examples/+showcase/, excl.examples/v1/**and_legacy/)showcase/**importing@copilotkit/runtimefrom "@copilotkit/runtime"; the real set is smaller but includes single-quoted and factory-only files it missedcreateCopilotEndpointRemaining
showcase/integrations/**(239 files) is handled in refactor(showcase): retire the v1 runtime adapter across every integration #6618.examples/v1/**(12 files) is deliberately v1 and never in scope. The rest ofexamples/is not in either PR.🤖 Generated with Claude Code