Repository navigation
chore: use agui with research canvas tests - #2018
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
## Walkthrough
The changes update three `@copilotkit` dependencies to version 1.9.2-next.7 in the UI package. In the API route handler, the initialization of `CopilotRuntime` is revised to support multiple named agents using `LangGraphAgent` instances, replacing the previous single-endpoint approach and removing the use of `langGraphPlatformEndpoint`. Additionally, interrupt handling in the runtime is refactored to remove a global flag, using thread-local interrupt state and a new helper function to emit interrupts more reliably.
## Changes
| File(s) | Change Summary |
|------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
| examples/coagents-research-canvas/ui/package.json | Updated `@copilotkit/react-core`, `@copilotkit/react-ui`, and `@copilotkit/runtime` dependencies to version 1.9.2-next.7. |
| examples/coagents-research-canvas/ui/src/app/api/copilotkit/route.ts | Changed `CopilotRuntime` initialization to support multiple named agents via `LangGraphAgent`; removed old endpoint logic. |
| CopilotKit/.changeset/ninety-items-scream.md | Added patch update fixing interrupt handling by using active interrupt from current thread context instead of global variable. |
| CopilotKit/packages/runtime/src/lib/runtime/remote-lg-action.ts | Refactored interrupt handling in `streamEvents`: removed global interrupt flag, introduced `emitInterrupt` helper, improved interrupt resolution and emission logic. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant Client
participant API_Route
participant CopilotRuntime
participant LangGraphAgent
Client->>API_Route: POST request
API_Route->>CopilotRuntime: Initialize with copilotKitEndpoint
alt deploymentUrl set and not isCrewAi
API_Route->>LangGraphAgent: Instantiate research_agent (graphId: research_agent)
API_Route->>LangGraphAgent: Instantiate research_agent_google_genai (graphId: research_agent_google_genai)
API_Route->>CopilotRuntime: Re-initialize with agents {research_agent, research_agent_google_genai}
end
API_Route->>CopilotRuntime: Handle request via copilotRuntimeNextJSAppRouterEndpoint
CopilotRuntime-->>API_Route: Response
API_Route-->>Client: ResponsePossibly related PRs
Suggested reviewers
|
466ddf8 to
2c780ef
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
examples/coagents-research-canvas/ui/src/app/api/copilotkit/route.ts (1)
22-46: Consider refactoring for efficiency and add error handling.The current implementation creates a runtime instance twice when
deploymentUrlis set and!isCrewAi. While functionally correct, this is inefficient as the first runtime is discarded.Consider refactoring to avoid creating unnecessary runtime instances:
- let runtime = new CopilotRuntime({ - remoteEndpoints: [ - copilotKitEndpoint({ - url: - process.env.REMOTE_ACTION_URL || "http://localhost:8000/copilotkit", - }) - ], - }) - - if (deploymentUrl && !isCrewAi) { - runtime = new CopilotRuntime({ - agents: { - 'research_agent': new LangGraphAgent({ - deploymentUrl, - langsmithApiKey, - graphId: 'research_agent', - }), - 'research_agent_google_genai': new LangGraphAgent({ - deploymentUrl, - langsmithApiKey, - graphId: 'research_agent_google_genai', - }) - } - }) - } + let runtime: CopilotRuntime; + + if (deploymentUrl && !isCrewAi) { + try { + runtime = new CopilotRuntime({ + agents: { + 'research_agent': new LangGraphAgent({ + deploymentUrl, + langsmithApiKey, + graphId: 'research_agent', + }), + 'research_agent_google_genai': new LangGraphAgent({ + deploymentUrl, + langsmithApiKey, + graphId: 'research_agent_google_genai', + }) + } + }); + } catch (error) { + console.error('Failed to create LangGraph agents:', error); + // Fallback to default runtime + runtime = new CopilotRuntime({ + remoteEndpoints: [ + copilotKitEndpoint({ + url: process.env.REMOTE_ACTION_URL || "http://localhost:8000/copilotkit", + }) + ], + }); + } + } else { + runtime = new CopilotRuntime({ + remoteEndpoints: [ + copilotKitEndpoint({ + url: process.env.REMOTE_ACTION_URL || "http://localhost:8000/copilotkit", + }) + ], + }); + }This refactor:
- Avoids creating unnecessary runtime instances
- Adds error handling for agent creation failures
- Provides a fallback mechanism
- Makes the conditional logic more explicit
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
CopilotKit/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlexamples/coagents-research-canvas/ui/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (3)
CopilotKit/packages/runtime/package.json(1 hunks)examples/coagents-research-canvas/ui/package.json(1 hunks)examples/coagents-research-canvas/ui/src/app/api/copilotkit/route.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Test (18.x)
- GitHub Check: Test (20.x)
🔇 Additional comments (3)
CopilotKit/packages/runtime/package.json (1)
53-53: Verify the alpha version exists and assess stability implications.The dependency was updated to an alpha version (
0.0.4-alpha.0), which may introduce instability or breaking changes. Ensure this version is available and consider the implications of using an alpha release in production.#!/bin/bash # Check if the alpha version exists on npm npm view @ag-ui/[email protected] version # Check for recent versions and release notes npm view @ag-ui/langgraph versions --json | jq '.[-5:]'examples/coagents-research-canvas/ui/package.json (1)
12-14: Verify the updated package versions are available.The three @CopilotKit packages were updated from
1.8.13to1.9.1. Ensure these versions exist and are compatible with the runtime changes.#!/bin/bash # Check if the updated versions exist on npm npm view @copilotkit/[email protected] version npm view @copilotkit/[email protected] version npm view @copilotkit/[email protected] version # Check for any breaking changes in changelog between 1.8.13 and 1.9.1 npm view @copilotkit/runtime versions --json | jq '.[]' | grep -E "1\.[89]\."examples/coagents-research-canvas/ui/src/app/api/copilotkit/route.ts (1)
6-6: LGTM!The import of
LangGraphAgentis correctly added to support the new agent-based runtime configuration.
2c780ef to
f12fcef
Compare
f12fcef to
9c4d75b
Compare
🦋 Changeset detectedLatest commit: 74712a3 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 |
|
Preview environments destroyed for this pull request. |
Test ResultsStatus: ✅ Passed (View Run) Commit: d4d077f Duration: 239.1s Total Tests: 20 Pass Rate: 100.0% Failed Tests: 0 🔍 Detailed Resultscoagents-research-canvasCoAgents Research Canvas (UI) - Local Depenencies
coagents-qa-nativeCoAgents QA Native (UI) - Local
coagents-qa-textCoAgents QA Text (UI) - Local
coagents-routingCoAgents Routing (UI) - Local
next-openaiNext OpenAI - Self Hosted
|
Replacing the current remote endpoint for langgraph platform with the new AGUI agent on research canvas demo
Summary by CodeRabbit
Chores
@copilotkitdependencies to version 1.9.2-next.7.Bug Fixes