Repository navigation
feat: integrate AG-UI LangGraph agent in CopilotKit - #1968
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
WalkthroughThe changes introduce a CopilotKit-specific LangGraph agent by adding a new dependency, implementing a custom agent class with specialized event handling, and updating API usage to support multiple named agents. Type safety and enum usage are improved in the demo viewer. Package versions are updated, and documentation and configuration files are revised accordingly. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API_Route
participant CopilotRuntime
participant LangGraphAgent
participant AGUILangGraphAgent
Client->>API_Route: POST /api/copilotkit?langgraph=true
API_Route->>CopilotRuntime: Initialize with named agents (LangGraphAgent instances)
API_Route->>LangGraphAgent: Run agent (input, metadata)
LangGraphAgent->>AGUILangGraphAgent: Superclass run logic
AGUILangGraphAgent-->>LangGraphAgent: Event stream
LangGraphAgent->>LangGraphAgent: Custom event dispatching, state merging, intermediate state prediction
LangGraphAgent->>API_Route: Stream processed events
API_Route->>Client: Respond with event stream
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (7)
🧰 Additional context used🪛 Biome (1.9.4)CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts[error] 44-46: This constructor is unnecessary. Unsafe fix: Remove the unnecessary constructor. (lint/complexity/noUselessConstructor) ⏰ Context from checks skipped due to timeout of 90000ms (2)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 8
🧹 Nitpick comments (4)
CopilotKit/packages/runtime/package.json (1)
53-53: Add new dependency for LangGraph integration
Dependency@ag-ui/langgraphis required by the newLangGraphAgentimplementation and correctly added here.Consider adding
@ag-ui/langgraphtopeerDependencies(>=0.0.1) to align with the other AG-UI packages and enforce consistent versioning for consumers.docs/content/docs/(root)/guides/backend-actions/langgraph-platform-endpoint.mdx (1)
62-80: Update snippet to use newagentsconfig object
The example correctly shows how to instantiateLangGraphAgentwithin theagentsmap.In the import block, ensure there’s a comma after
LangGraphAgentfor valid TS syntax:-import { - CopilotRuntime, - LangGraphAgent // [!code highlight] - // ... -} from "@copilotkit/runtime"; +import { + CopilotRuntime, + LangGraphAgent, // [!code highlight] + // ... +} from "@copilotkit/runtime";Also verify that the backtick fences and MDX code markers render correctly.
docs/content/docs/coagents/tutorials/ai-travel-app/step-4-integrate-the-agent.mdx (1)
73-87: Self-Hosted snippet: ensure valid import and config syntax
The Self-Hosted example correctly replaces the oldremoteEndpointspattern withagents.
- Add a trailing comma after
LangGraphAgentin the import block.- Double-check that the removed
const runtime = new CopilotRuntime();and the new instantiation block render as intended in MDX.-import { CopilotRuntime, LangGraphAgent } from '@copilotkit/runtime'; // [!code ++] +import { CopilotRuntime, LangGraphAgent, } from '@copilotkit/runtime'; // [!code ++]examples/demo-viewer/agent/demo/langgraph_shared_state/page.tsx (1)
288-288: Remove debug console.log statement.Debug statements should be removed before merging to production.
- console.log(recipe)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
CopilotKit/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (9)
CopilotKit/packages/runtime/package.json(1 hunks)CopilotKit/packages/runtime/src/lib/index.ts(1 hunks)CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts(1 hunks)docs/content/docs/(root)/guides/backend-actions/langgraph-platform-endpoint.mdx(1 hunks)docs/content/docs/coagents/troubleshooting/common-issues.mdx(2 hunks)docs/content/docs/coagents/tutorials/ai-travel-app/step-4-integrate-the-agent.mdx(2 hunks)docs/snippets/self-hosting-remote-endpoints.mdx(2 hunks)examples/demo-viewer/agent/demo/langgraph_shared_state/page.tsx(5 hunks)examples/demo-viewer/agent/pyproject.toml(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
examples/demo-viewer/agent/demo/langgraph_shared_state/page.tsx (2)
examples/demo-viewer/agent/demo/langgraph_shared_state/agent.py (1)
SpecialPreferences(33-43)examples/demo-viewer/agent/demo/crewai_shared_state/agent.py (1)
Recipe(106-115)
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts (1)
registry/registry/quickstarts/mcp-starter/utils/mcp-client.ts (1)
tools(115-234)
🪛 Biome (1.9.4)
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts
[error] 40-42: This constructor is unnecessary.
Unsafe fix: Remove the unnecessary constructor.
(lint/complexity/noUselessConstructor)
🪛 GitHub Actions: Quality
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts
[warning] 1-1: Prettier formatting check failed. Code style issues found in this file. Run Prettier with --write to fix.
⏰ Context from checks skipped due to timeout of 90000ms (11)
- GitHub Check: Build Images (next-openai, next-openai)
- GitHub Check: Build Images (coagents-routing, agent, python, local-deps)
- GitHub Check: Build Images (coagents-qa-native, ui)
- GitHub Check: Build Images (coagents-qa-text, ui)
- GitHub Check: Build Images (coagents-qa-text, agent, python, local-deps)
- GitHub Check: Build Images (coagents-qa-native, agent, python, local-deps)
- GitHub Check: Build Images (coagents-research-canvas, ui)
- GitHub Check: Build Images (coagents-routing, ui)
- GitHub Check: Build Images (coagents-research-canvas, agent, python, local-deps)
- GitHub Check: Test (20.x)
- GitHub Check: Test (18.x)
🔇 Additional comments (10)
CopilotKit/packages/runtime/src/lib/index.ts (1)
11-11: Expose the new LangGraphAgent in the public API
Great addition—re-exporting./runtime/langgraph/langgraph-agentmakesLangGraphAgentavailable to end users.docs/content/docs/coagents/tutorials/ai-travel-app/step-4-integrate-the-agent.mdx (1)
18-22: Clarify registration step
The updated intro clearly signals that you will register an agent and then wire it up withuseCoAgent. The phrasing is concise and matches the new API surface.docs/content/docs/coagents/troubleshooting/common-issues.mdx (1)
125-134: Documentation correctly shows the new agent registration pattern.The example properly demonstrates the new approach using the
agentsobject withLangGraphAgentinstances.docs/snippets/self-hosting-remote-endpoints.mdx (2)
11-25: Documentation snippet correctly shows the new pattern.The Local (LangGraph Studio) tab properly demonstrates the new
LangGraphAgentusage.
50-64: LangGraph Platform configuration is consistent.The example maintains consistency with the Local tab, showing the same agent registration pattern.
examples/demo-viewer/agent/demo/langgraph_shared_state/page.tsx (2)
82-93: Good refactoring to use TypeScript enum for type safety.The
SpecialPreferencesenum provides better type safety and matches the Python backend enum values.
98-98: Property rename is consistently applied throughout.The rename from
dietary_preferencestospecial_preferencesis applied consistently across the interface, state, handlers, and UI.Also applies to: 112-112, 203-215, 352-352, 359-360
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts (3)
44-140: Event dispatching logic is well-structured.The implementation properly handles CopilotKit-specific custom events and conditionally filters tool/message events based on metadata flags. The separation of concerns between custom and standard events is clean.
171-179: State merging customization looks good.The override properly wraps returned tools under the
copilotkit.actionskey, maintaining compatibility with CopilotKit's expected state structure.
142-143:Details
❓ Verification inconclusive
Remove @ts-ignore and fix the TypeScript issue properly.
Using
@ts-ignoresuppresses potentially important TypeScript errors. Consider fixing the underlying type issue instead.Can you investigate what TypeScript error is being suppressed here and provide a proper fix?
🏁 Script executed:
#!/bin/bash # Check the parent class definition to understand the type mismatch ast-grep --pattern 'class AGUILangGraphAgent { $$$ run($_) { $$$ } $$$ }'Length of output: 87
Let’s locate the parent class and inspect its
runmethod signature:
🏁 Script executed:
#!/bin/bash # 1. Locate the parent class file parent_file=$(rg -l "class AGUILangGraphAgent" -n . | head -n1) echo "Parent class file: $parent_file" # 2. Show the 'run' method signature and surrounding context rg -n "run" "$parent_file" -A3 -B3Length of output: 180
We need to inspect the local class and its supertype to see why
@ts-ignorewas added. Let’s dump the class declaration, itsextends, and therunsignature in this file, plus search globally for the parent class:
🏁 Script executed:
#!/bin/bash # File under review file="CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts" echo "=== Inspecting $file ===" rg -n "class " "$file" -n rg -n "extends " "$file" -n rg -n "run(" "$file" -A3 -B3 echo echo "=== Searching for parent class globally ===" rg -n "AGUILangGraphAgent" -n .Length of output: 1125
Let’s dump the top of the file to see the import/alias and find the real parent:
🏁 Script executed:
#!/bin/bash file="CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts" echo "=== First 60 lines of $file ===" sed -n '1,60p' "$file"Length of output: 2407
Align
runoverride with the parent signature instead of using@ts-ignoreRemove the
@ts-ignoreon line 142 of
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts
and update therunmethod to exactly match the parameter and return types of
AGUILangGraphAgent.run(…)from the@ag-ui/langgraphpackage.• File:
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts
- Delete the
// @ts-ignoreaboverun(input: RunAgentInput)- Adjust the
run(...)signature (and its return type) to align with the externalAGUILangGraphAgentdeclarationPlease check the TypeScript definitions in
@ag-ui/langgraph(e.g. its.d.tsfiles) to verify the correct method signature and return type.
| [project] | ||
| name = "demo" | ||
| version = "0.0.1" | ||
|
|
There was a problem hiding this comment.
Duplicate project metadata and version mismatch
You've introduced a PEP 621 [project] table with version = "0.0.1" alongside the existing [tool.poetry] version = "0.1.0". This creates conflicting version declarations.
Please remove the redundant [project] table or synchronize the version numbers to avoid build errors and confusion.
🤖 Prompt for AI Agents
In examples/demo-viewer/agent/pyproject.toml around lines 8 to 11, there is a
duplicate project metadata section with conflicting version numbers between the
[project] table and the existing [tool.poetry] section. To fix this, either
remove the redundant [project] table entirely or update its version to match the
version specified in [tool.poetry] to ensure consistency and prevent build
errors.
| 'agent-name', new LangGraphAgent({({ | ||
| deploymentUrl: "https://your-fastapi-endpoint:port", | ||
| langsmithApiKey: <langsmith API key> | ||
| graphId: 'langgraph.json graph id', // Your previous graphId definition | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Fix syntax error in the code example.
The code example has multiple syntax errors that would confuse users.
Apply this diff to fix the syntax:
- 'agent-name', new LangGraphAgent({({
+ 'agent-name': new LangGraphAgent({
deploymentUrl: "https://your-fastapi-endpoint:port",
- langsmithApiKey: <langsmith API key>
+ langsmithApiKey: '<langsmith API key>',
graphId: 'langgraph.json graph id', // Your previous graphId definition
- },
+ }),
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| 'agent-name', new LangGraphAgent({({ | |
| deploymentUrl: "https://your-fastapi-endpoint:port", | |
| langsmithApiKey: <langsmith API key> | |
| graphId: 'langgraph.json graph id', // Your previous graphId definition | |
| }, | |
| }); | |
| 'agent-name': new LangGraphAgent({ | |
| deploymentUrl: "https://your-fastapi-endpoint:port", | |
| langsmithApiKey: '<langsmith API key>', | |
| graphId: 'langgraph.json graph id', // Your previous graphId definition | |
| }), | |
| }); |
🤖 Prompt for AI Agents
In docs/content/docs/coagents/troubleshooting/common-issues.mdx around lines 236
to 241, the code example has syntax errors such as misplaced parentheses and
missing commas. Fix the syntax by properly structuring the object passed to the
LangGraphAgent constructor: remove extraneous parentheses, add missing commas
between properties, and ensure the object and function call are correctly
closed.
| constructor(config: LangGraphAgentConfig) { | ||
| super(config); | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Remove unnecessary constructor.
The constructor only calls super without adding any functionality.
- constructor(config: LangGraphAgentConfig) {
- super(config);
- }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| constructor(config: LangGraphAgentConfig) { | |
| super(config); | |
| } |
🧰 Tools
🪛 Biome (1.9.4)
[error] 40-42: This constructor is unnecessary.
Unsafe fix: Remove the unnecessary constructor.
(lint/complexity/noUselessConstructor)
🤖 Prompt for AI Agents
In CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts at
lines 40 to 42, the constructor is redundant as it only calls super with the
same config parameter without adding any extra logic. Remove the entire
constructor method to simplify the class definition and rely on the default
constructor behavior.
4bed733 to
6cfcf1a
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts (1)
44-46: Remove the unnecessary constructor.This constructor only calls
super(config)without adding any functionality and should be removed to simplify the class definition.- constructor(config: LangGraphAgentConfig) { - super(config); - }🧰 Tools
🪛 Biome (1.9.4)
[error] 44-46: This constructor is unnecessary.
Unsafe fix: Remove the unnecessary constructor.
(lint/complexity/noUselessConstructor)
🧹 Nitpick comments (3)
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts (3)
50-51: Simplify redundant type casting.The type casting on line 51 is redundant since
eventis already typed asProcessedEventsfrom the parameter.- // const event = processedEvent as unknown as CustomEvent; - const customEvent = event as unknown as CustomEvent; + const customEvent = event as unknown as CustomEvent;Or better yet, add proper type guards to avoid the need for type assertions.
153-153: Improve null safety for event data access.The nested optional chaining could be more robust to prevent potential runtime errors.
Consider adding explicit null checks or using a more defensive approach:
- const event = (processedEvent as RawEvent).event ?? (processedEvent as RawEvent).rawEvent; + const rawEventData = processedEvent as RawEvent; + const event = rawEventData.event ?? rawEventData.rawEvent; + if (!event) return processedEvent;
159-161: Add safety check for metadata access.The metadata access could benefit from additional null safety to prevent runtime errors.
- const toolCallUsedToPredictState = event.metadata?.[ - "copilotkit:emit-intermediate-state" - ]?.some( - (predictStateTool: PredictStateTool) => predictStateTool.tool === toolCallData?.name, - ); + const toolCallUsedToPredictState = event.metadata?.["copilotkit:emit-intermediate-state"]?.some( + (predictStateTool: PredictStateTool) => + predictStateTool?.tool === toolCallData?.name + ) ?? false;
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
CopilotKit/.changeset/modern-vans-perform.md(1 hunks)CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts(1 hunks)docs/content/docs/coagents/troubleshooting/common-issues.mdx(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- CopilotKit/.changeset/modern-vans-perform.md
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/content/docs/coagents/troubleshooting/common-issues.mdx
🧰 Additional context used
🧬 Code Graph Analysis (1)
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts (1)
registry/registry/quickstarts/mcp-starter/utils/mcp-client.ts (1)
tools(115-234)
🪛 Biome (1.9.4)
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts
[error] 44-46: This constructor is unnecessary.
Unsafe fix: Remove the unnecessary constructor.
(lint/complexity/noUselessConstructor)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Test (18.x)
- GitHub Check: Test (20.x)
🔇 Additional comments (1)
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts (1)
177-189: Well-structured state merging implementation.The
langGraphDefaultMergeStatemethod correctly wraps tools under thecopilotkit.actionskey while preserving other state properties. The destructuring approach is clean and maintainable.
| return true; | ||
| } | ||
|
|
||
| // @ts-ignore |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Address the TypeScript ignore directive.
The @ts-ignore comment suggests there may be a type incompatibility in the method signature override. This should be resolved properly rather than suppressed.
Please investigate and fix the underlying type issue instead of using @ts-ignore. If the base class method signature is incompatible, consider:
- Updating the method signature to match the base class
- Using proper type assertions if the override is intentional
- Adding proper JSDoc comments explaining why the override is necessary
🤖 Prompt for AI Agents
In CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts at
line 146, remove the @ts-ignore directive by investigating the type
incompatibility causing the error. Fix the method signature to properly match
the base class method it overrides, or if intentional, use correct type
assertions and add JSDoc comments explaining the override rationale. This
ensures type safety without suppressing errors.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
examples/demo-viewer/src/app/api/copilotkit/route.ts (1)
21-29: Consider refactoring agent creation to reduce duplication.While the explicit agent configuration is functional and clear for a demo, consider extracting the agent creation logic to reduce duplication:
+ const agentNames = [ + "agentic_chat", + "agentic_generative_ui", + "human_in_the_loop", + "predictive_state_updates", + "shared_state", + "tool_based_generative_ui", + "no_chat" + ]; + + const agents = Object.fromEntries( + agentNames.map(name => [name, new LangGraphAgent({ deploymentUrl, graphId: name })]) + ); + runtime = new CopilotRuntime({ - agents: { - "agentic_chat": new LangGraphAgent({ deploymentUrl, graphId: 'agentic_chat' }), - "agentic_generative_ui": new LangGraphAgent({ deploymentUrl, graphId: 'agentic_generative_ui' }), - "human_in_the_loop": new LangGraphAgent({ deploymentUrl, graphId: 'human_in_the_loop' }), - "predictive_state_updates": new LangGraphAgent({ deploymentUrl, graphId: 'predictive_state_updates' }), - "shared_state": new LangGraphAgent({ deploymentUrl, graphId: 'shared_state' }), - "tool_based_generative_ui": new LangGraphAgent({ deploymentUrl, graphId: 'tool_based_generative_ui' }), - "no_chat": new LangGraphAgent({ deploymentUrl, graphId: 'no_chat' }) - } + agents });This would make it easier to maintain the agent list and reduce repetitive code.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
examples/demo-viewer/src/app/api/copilotkit/route.ts(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
examples/demo-viewer/src/app/api/copilotkit/route.ts (1)
CopilotKit/packages/runtime/src/lib/runtime/copilot-runtime.ts (1)
CopilotRuntime(276-1217)
⏰ Context from checks skipped due to timeout of 90000ms (11)
- GitHub Check: Build Images (next-openai, next-openai)
- GitHub Check: Build Images (coagents-qa-native, ui)
- GitHub Check: Build Images (coagents-qa-text, ui)
- GitHub Check: Build Images (coagents-qa-native, agent, python, local-deps)
- GitHub Check: Build Images (coagents-qa-text, agent, python, local-deps)
- GitHub Check: Build Images (coagents-research-canvas, ui)
- GitHub Check: Build Images (coagents-routing, ui)
- GitHub Check: Build Images (coagents-routing, agent, python, local-deps)
- GitHub Check: Build Images (coagents-research-canvas, agent, python, local-deps)
- GitHub Check: Test (20.x)
- GitHub Check: Test (18.x)
🔇 Additional comments (2)
examples/demo-viewer/src/app/api/copilotkit/route.ts (2)
5-5: LGTM! Import addition aligns with new agent integration.The import of
LangGraphAgentis necessary for the new agent configuration approach and aligns with the PR objective of integrating AG-UI LangGraph agent.
19-19: Environment variable naming is clear and follows convention.The use of
LG_DEPLOYMENT_URLenvironment variable with a sensible fallback to localhost is appropriate for demo purposes.
9c9c873 to
884030f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (2)
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts (2)
44-46: Redundant constructor still present – remove itThe constructor only delegates to
superwith the same argument and adds no behaviour. Static analysis already flagged this (noUselessConstructor). Delete the constructor to reduce noise.🧰 Tools
🪛 Biome (1.9.4)
[error] 44-46: This constructor is unnecessary.
Unsafe fix: Remove the unnecessary constructor.
(lint/complexity/noUselessConstructor)
146-147:@ts-ignorehides a real type-mismatch – please fix the signature insteadSuppressing the error masks potential runtime issues and defeats the purpose of strict typing. Align the override with the base class signature (likely
run<T extends RunAgentInput>(input: T): Observable<ProcessedEvents>), or perform a proper type assertion.
🧹 Nitpick comments (2)
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts (2)
48-71: Factor out the three consecutivesubscriber.nextcalls to avoid duplicationThe manual message emission repeats the same pattern (START → CONTENT → END). Extracting a small helper (e.g.,
emitAssistantMessage(messageId, text, raw)) will:• remove repetition (six nearly-identical objects across message & tool call branches)
• reduce the chance of future inconsistencies (e.g., forgetting to includerawEvent)
74-94: Same duplication pattern for tool callsAs above, emitting START/ARGS/END can be abstracted into
emitToolCall(...)to centralise the logic and keepdispatchEventreadable.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
CopilotKit/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (11)
CopilotKit/.changeset/modern-vans-perform.md(1 hunks)CopilotKit/packages/runtime/package.json(1 hunks)CopilotKit/packages/runtime/src/lib/index.ts(1 hunks)CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts(1 hunks)docs/content/docs/(root)/guides/backend-actions/langgraph-platform-endpoint.mdx(1 hunks)docs/content/docs/coagents/troubleshooting/common-issues.mdx(2 hunks)docs/content/docs/coagents/tutorials/ai-travel-app/step-4-integrate-the-agent.mdx(2 hunks)docs/snippets/self-hosting-remote-endpoints.mdx(2 hunks)examples/demo-viewer/agent/demo/langgraph_shared_state/page.tsx(5 hunks)examples/demo-viewer/agent/pyproject.toml(1 hunks)examples/demo-viewer/src/app/api/copilotkit/route.ts(2 hunks)
✅ Files skipped from review due to trivial changes (3)
- CopilotKit/packages/runtime/package.json
- CopilotKit/packages/runtime/src/lib/index.ts
- docs/content/docs/coagents/tutorials/ai-travel-app/step-4-integrate-the-agent.mdx
🚧 Files skipped from review as they are similar to previous changes (7)
- CopilotKit/.changeset/modern-vans-perform.md
- examples/demo-viewer/agent/pyproject.toml
- examples/demo-viewer/src/app/api/copilotkit/route.ts
- docs/content/docs/(root)/guides/backend-actions/langgraph-platform-endpoint.mdx
- docs/content/docs/coagents/troubleshooting/common-issues.mdx
- docs/snippets/self-hosting-remote-endpoints.mdx
- examples/demo-viewer/agent/demo/langgraph_shared_state/page.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts
[error] 44-46: This constructor is unnecessary.
Unsafe fix: Remove the unnecessary constructor.
(lint/complexity/noUselessConstructor)
⏰ Context from checks skipped due to timeout of 90000ms (11)
- GitHub Check: Build Images (coagents-qa-text, agent, python, local-deps)
- GitHub Check: Build Images (coagents-qa-text, ui)
- GitHub Check: Build Images (next-openai, next-openai)
- GitHub Check: Build Images (coagents-routing, ui)
- GitHub Check: Build Images (coagents-research-canvas, agent, python, local-deps)
- GitHub Check: Build Images (coagents-qa-native, ui)
- GitHub Check: Build Images (coagents-routing, agent, python, local-deps)
- GitHub Check: Build Images (coagents-qa-native, agent, python, local-deps)
- GitHub Check: Build Images (coagents-research-canvas, ui)
- GitHub Check: Test (20.x)
- GitHub Check: Test (18.x)
| type LangGraphAgentConfig, | ||
| ProcessedEvents, | ||
| } from "@ag-ui/langgraph"; | ||
| import { Message as LangGraphMessage } from "@langchain/langgraph-sdk/dist/types.messages"; |
There was a problem hiding this comment.
Import uses a private dist/ path – switch to the public export before it breaks
@langchain/langgraph-sdk/dist/types.messages is an internal build artefact, not part of the package’s public API surface. Relying on it is brittle and will break as soon as the package author refactors the build output or ship ESM‐only bundles.
-import { Message as LangGraphMessage } from "@langchain/langgraph-sdk/dist/types.messages";
+import { Message as LangGraphMessage } from "@langchain/langgraph-sdk";📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { Message as LangGraphMessage } from "@langchain/langgraph-sdk/dist/types.messages"; | |
| -import { Message as LangGraphMessage } from "@langchain/langgraph-sdk/dist/types.messages"; | |
| +import { Message as LangGraphMessage } from "@langchain/langgraph-sdk"; |
🤖 Prompt for AI Agents
In CopilotKit/packages/runtime/src/lib/runtime/langgraph/langgraph-agent.ts at
line 20, the import statement uses a private internal path
'@langchain/langgraph-sdk/dist/types.messages' which is not part of the public
API and may break in future updates. Change the import to use the public API
export from '@langchain/langgraph-sdk' or another officially supported path
provided by the package to ensure stability and compatibility.
🦋 Changeset detectedLatest commit: 2253b17 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Click here if you're a maintainer who wants to add another changeset to this PR |
PreviewsCommit SHA: 9f63200
|
This PR introduces the AGUI LangGraph agent in CopilotKit
Summary by CodeRabbit
New Features
Improvements
Dependencies
Documentation