Skip to content

fix(examples): import LangGraphAgent from the langgraph subpath - #7120

Merged
BenTaylorDev merged 1 commit into
mainfrom
ben1/fix-langgraph-agent-root-import
Sep 14, 2026
Merged

BenTaylorDev merged 1 commit into
mainfrom
ben1/fix-langgraph-agent-root-import

Conversation

@BenTaylorDev

@BenTaylorDev BenTaylorDev commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

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

Summary by CodeRabbit

  • Bug Fixes
    • Updated example integrations to use the correct LangGraph runtime import configuration.
    • Removed an unused runtime import from the Gemini canvas example.

`LangGraphAgent` re-exported from the `@copilotkit/runtime` root is a stub
whose constructor throws:

    LangGraphAgent import from @copilotkit/runtime is deprecated.
    Please import it from @copilotkit/runtime/langgraph instead

Both canvas examples float their runtime pin (`^1.10.4` / `^1.9.3`), so a
fresh install resolves 1.71.1 and the stub is what they get.

- canvas/langgraph-python constructs it, so its `/api/copilotkit` route
  throws at module load and the example does not boot.
- canvas/gemini only imports the symbol and never constructs it, so it is a
  dead import of a throw-only stub. Removed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 3939c820-85f7-4322-947b-d77a85bbb01d

📥 Commits

Reviewing files that changed from the base of the PR and between 84984b0 and 26dd137.

📒 Files selected for processing (2)
  • examples/canvas/gemini/app/api/copilotkit/route.ts
  • examples/canvas/langgraph-python/src/app/api/copilotkit/route.ts

📝 Walkthrough

Walkthrough

The canvas examples update LangGraphAgent imports. The Gemini route removes an unused import. The LangGraph Python route changes the import path to @copilotkit/runtime/langgraph.

Changes

Canvas runtime imports

Layer / File(s) Summary
Align LangGraphAgent imports
examples/canvas/gemini/app/api/copilotkit/route.ts, examples/canvas/langgraph-python/src/app/api/copilotkit/route.ts
The Gemini route removes the unused LangGraphAgent import. The LangGraph Python route imports LangGraphAgent from @copilotkit/runtime/langgraph.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ben1/fix-langgraph-agent-root-import

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@BenTaylorDev
BenTaylorDev marked this pull request as ready for review September 14, 2026 16:36
@BenTaylorDev
BenTaylorDev merged commit 2ea2b3d into main Sep 14, 2026
14 of 15 checks passed
@BenTaylorDev
BenTaylorDev deleted the ben1/fix-langgraph-agent-root-import branch September 14, 2026 16:37
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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant