Skip to content

Cpk 2442 hitl option 2 add new items - #1934

Merged
copilotkit-support merged 4 commits into
mainfrom
CPK-2442-HITL-option-2-add-new-items
Jun 5, 2025
Merged

copilotkit-support merged 4 commits into
mainfrom
CPK-2442-HITL-option-2-add-new-items

Conversation

@copilotkit-support

@copilotkit-support copilotkit-support commented Jun 5, 2025 •

Copy link
Copy Markdown
Contributor

What does this PR do?

(Describe the changes introduced in this PR)

Related PRs and Issues

  • (Direct link to related PR or issue, if relevant)

Checklist

  • I have read the Contribution Guide
  • If the PR changes or adds functionality, I have updated the relevant documentation

Summary by CodeRabbit

  • New Features

    • Added the ability for users to dynamically add new steps during task execution in human-in-the-loop demos.
    • Introduced a visual step-by-step progress indicator for agent flows, including animated transitions and dark mode support.
  • Enhancements

    • Improved the instructions for task summaries to include user-added steps.
    • Reduced waiting times for agent flows, making interactions faster.

…Implemented a new input field in both demo viewers to allow users to add steps dynamically during the execution phase. Added functionality to handle step addition via keyboard input, enhancing user interaction.
…oop demo viewers. Updated the input field styles in both demo viewers to enhance visual consistency.
@linear

linear Bot commented Jun 5, 2025

Copy link
Copy Markdown

@vercel

vercel Bot commented Jun 5, 2025 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ag2-feature-viewer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
ag2-starter ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
coagents-starter-crewai-flows ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
copilot-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
copilot-kit-qd8p ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
copilot-kit-wq8x ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
copilot-mastra-starter ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
copilotkit-feature-viewer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
copilotkit-mastra-feature-viewer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
demo-viewer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
examples-coagents-ai-travel-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
examples-coagents-research-canvas-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 11:42am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
examples-coagents-ai-researcher-ui ⬜️ Ignored (Inspect) Visit Preview Jun 5, 2025 11:42am

@coderabbitai

coderabbitai Bot commented Jun 5, 2025 •

Copy link
Copy Markdown
Contributor
## Walkthrough

The changes introduce the ability for users to dynamically add new steps during task execution in multiple human-in-the-loop demo pages by adding new state variables and handlers for step input. The no-chat demo is enhanced with a stepwise wizard UI showing progress, and agent flow delays are reduced. The prompt instructions are updated to include user-added steps in summaries. The langgraph server code is simplified by removing an indirection function and directly instantiating agents.

## Changes

| File(s)                                                                                     | Change Summary                                                                                                  |
|--------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|
| `examples/demo-viewer/agent/demo/crewai_human_in_the_loop/page.tsx`<br>`.../standard_human_in_the_loop/page.tsx`<br>`.../langgraph_human_in_the_loop/page.tsx` | Added state and handlers for user to input and add new steps during execution; updated UI to show input field.  |
| `examples/demo-viewer/src/files.json`                                                      | Added stepwise wizard UI with progress indicators in no-chat demo; reduced sleep durations in agent flow nodes. |
| `examples/demo-viewer/src/lib/prompts.ts`                                                  | Updated instruction string to require summaries to include user-added steps.                                   |
| `examples/demo-viewer/agent/demo/langgraph_server.py`                                     | Removed `create_agents` function; instantiated agents inline when creating `CopilotKitSDK` instance.           |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant UI
    participant StepsState

    User->>UI: Enter new step in input field
    UI->>StepsState: handleAddStep(newStep)
    StepsState->>StepsState: Add new step to localSteps
    StepsState->>UI: Update steps display

Suggested reviewers

  • mme
  • ataibarkai
  • ranst91

<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: .coderabbit.yaml**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between ec56586cb11c21f782bff7a09c6bda965c5cd65b and 5d9370a70574bce0e9e02450c6ce5df438ab4b3c.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `examples/demo-viewer/agent/demo/langgraph_server.py` (1 hunks)

</details>

<details>
<summary>✅ Files skipped from review due to trivial changes (1)</summary>

* examples/demo-viewer/agent/demo/langgraph_server.py

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (9)</summary>

* GitHub Check: Build Images (coagents-qa-native, ui)
* GitHub Check: Build Images (next-openai, next-openai)
* GitHub Check: Build Images (coagents-routing, ui)
* GitHub Check: Build Images (coagents-qa-native, agent, python, local-deps)
* GitHub Check: Build Images (coagents-qa-text, ui)
* GitHub Check: Build Images (coagents-qa-text, agent, python, local-deps)
* GitHub Check: Build Images (coagents-research-canvas, agent, python, local-deps)
* GitHub Check: Build Images (coagents-routing, agent, python, local-deps)
* GitHub Check: Build Images (coagents-research-canvas, ui)

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAYW4Aa0gAJgAWVOTIBAj+bnF8LEy0WnpyAHcUGmZEaMgytGQHAWZ1Gno5MNgPbERKfgoGNDAmbngvfFwE9XRkW0gMRwE+gEYATgBmVJQsXC7IWPxR8dwAaWn/bn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MGcgfcHbwC8gZumk9wCmCOCj9vkEskiioGijsjikcg89UhnxaCBOdEQBRKjCJqrILmsPik86toAHY6Bkg/hkgBBVgBBkhlgAAOAQZYAQcrq29IAANmWFSBy4AFYBB1hyvWvSv6vVASByuGAWvMhlJPPRAWv6uWvyv6uGAqvlgGAyu/gcvyuivIScu0ArbVgGAeugxVhxuBuGBaBxuBAHInI4uWvaANgcura0BLuWucvUgBB0QraSBVgSAra0gWurbNv0Qzu/hUgOuVB7v1g0wsu4vPd1B6pVSUvJWqz1J9AgA= -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=CopilotKit/CopilotKit&utm_content=1934):

> ‼️ **IMPORTANT**
> Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) 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)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
examples/demo-viewer/agent/demo/standard_human_in_the_loop/page.tsx (1)

73-73: Remove debugger statement.

The debugger statement should be removed before merging to production.

-  debugger
🧰 Tools
🪛 Biome (1.9.4)

[error] 73-73: This is an unexpected use of the debugger statement.

Unsafe fix: Remove debugger statement

(lint/suspicious/noDebugger)

examples/demo-viewer/src/files.json (2)

482-489: Use forward slashes for file paths
The current path uses Windows-style separators which may not resolve correctly on Unix-based environments or in the demo viewer.
Apply this diff to update the path:

-        "path": "langgraph_no_chat\\agent.py",
+        "path": "langgraph_no_chat/agent.py",

490-495: Normalize path separator and verify language tag
Similarly, update the path for page.tsx and ensure the syntax highlighting language matches .tsx content:

-        "path": "langgraph_no_chat\\page.tsx",
+        "path": "langgraph_no_chat/page.tsx",

If your viewer supports React/TSX highlighting, consider changing "language": "typescript" to "language": "tsx" or "typescriptreact".

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7800c9 and 07ed2f2.

📒 Files selected for processing (4)
  • examples/demo-viewer/agent/demo/crewai_human_in_the_loop/page.tsx (3 hunks)
  • examples/demo-viewer/agent/demo/standard_human_in_the_loop/page.tsx (2 hunks)
  • examples/demo-viewer/src/files.json (1 hunks)
  • examples/demo-viewer/src/lib/prompts.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Build Images (coagents-qa-native, ui)
  • GitHub Check: Build Images (coagents-qa-native, agent, python, local-deps)
  • GitHub Check: Build Images (next-openai, next-openai)
  • GitHub Check: Build Images (coagents-qa-text, ui)
  • 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, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-routing, ui)
  • GitHub Check: Build Images (coagents-research-canvas, agent, python, local-deps)
🔇 Additional comments (5)
examples/demo-viewer/src/lib/prompts.ts (1)

50-50: LGTM! Prompt instruction properly aligns with new UI capability.

The addition to include user-added steps in summaries correctly reflects the new dynamic step addition functionality being introduced in the UI components.

examples/demo-viewer/agent/demo/crewai_human_in_the_loop/page.tsx (3)

71-71: Good state management for new step input.

The new state variable is properly initialized and will track the input field value correctly.


98-112: Well-implemented handlers with proper input validation.

The functions handle edge cases appropriately:

  • Input trimming prevents whitespace-only entries
  • Functional state updates maintain immutability
  • Enter key handling provides good UX
  • Functions are defined at component level for optimal performance

143-153: Input field properly integrated with existing UI.

The controlled input is well-implemented with:

  • Proper event binding
  • Conditional visibility based on execution status
  • Consistent styling with existing components
  • Clear placeholder text
examples/demo-viewer/agent/demo/standard_human_in_the_loop/page.tsx (1)

104-114: Input field implementation looks good.

The controlled input field is properly implemented with correct event handling and conditional visibility.

Comment on lines +44 to +60
const [newStep, setNewStep] = useState("");

const handleAddStep = () => {
const trimmed = newStep.trim();
if (trimmed.length === 0) return;
setLocalSteps((prevSteps) => [
...prevSteps,
{ description: trimmed, status: "enabled" },
]);
setNewStep("");
};

const handleInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === "Enter") {
handleAddStep();
}
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refactor function definitions outside of render callback.

The handler functions are defined inside the renderAndWaitForResponse callback, which causes them to be recreated on every render. This impacts performance and could lead to unnecessary re-renders.

Consider moving these functions outside the callback or using useCallback to memoize them:

renderAndWaitForResponse: ({ args, respond, status }) => {
+  const handleAddStep = useCallback(() => {
+    const trimmed = newStep.trim();
+    if (trimmed.length === 0) return;
+    setLocalSteps((prevSteps) => [
+      ...prevSteps,
+      { description: trimmed, status: "enabled" },
+    ]);
+    setNewStep("");
+  }, [newStep]);
+
+  const handleInputKeyDown = useCallback((e: React.KeyboardEvent<HTMLInputElement>) => {
+    if (e.key === "Enter") {
+      handleAddStep();
+    }
+  }, [handleAddStep]);

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In examples/demo-viewer/agent/demo/standard_human_in_the_loop/page.tsx around
lines 44 to 60, the handler functions handleAddStep and handleInputKeyDown are
defined inside the renderAndWaitForResponse callback, causing them to be
recreated on every render and impacting performance. To fix this, move these
functions outside the callback or wrap them with React's useCallback hook to
memoize them, ensuring they are only recreated when their dependencies change.

… functionality to dynamically add steps via an input field and handle keyboard events for better user interaction during the execution phase.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🔭 Outside diff range comments (1)
examples/demo-viewer/agent/demo/langgraph_human_in_the_loop/page.tsx (1)

22-118: 🛠️ Refactor suggestion

Good functionality implementation with architectural improvements needed.

The dynamic step addition feature works well and integrates seamlessly with the existing step management logic. The user experience is intuitive with proper validation and state updates.

However, the overall architecture should be improved by moving state and handlers outside the render function as mentioned in the previous comments. This will improve performance and follow React best practices while maintaining the same functionality.

🧰 Tools
🪛 Biome (1.9.4)

[error] 43-43: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🧹 Nitpick comments (1)
examples/demo-viewer/agent/demo/langgraph_human_in_the_loop/page.tsx (1)

93-103: Address the commented code and improve accessibility.

The input field implementation looks good, but there's commented code that suggests incomplete logic.

Consider the following improvements:

  1. Address the commented line - determine if this visibility logic is needed:
-                // hidden={status != "executing"}
  1. Add accessibility attributes for better UX:
  <input
    type="text"
+   id="new-step-input"
+   aria-label="Add a new step"
    className="flex-1 rounded py-2 focus:outline-none"
    placeholder="Add a new step..."
    value={newStep}
    onChange={(e) => setNewStep(e.target.value)}
    onKeyDown={handleInputKeyDown}
  />
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07ed2f2 and ec56586.

📒 Files selected for processing (2)
  • examples/demo-viewer/agent/demo/langgraph_human_in_the_loop/page.tsx (2 hunks)
  • examples/demo-viewer/src/files.json (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • 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-qa-native, ui)
  • GitHub Check: Build Images (next-openai, next-openai)
  • GitHub Check: Build Images (coagents-qa-text, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-qa-text, ui)
  • 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)
🔇 Additional comments (2)
examples/demo-viewer/src/files.json (2)

74-80: Approve CrewAI HIL component JSON entry
The JSON entry for crewai_human_in_the_loop/page.tsx is well-formed, and the content string is properly escaped. Path separators are consistent with other entries.


482-489: Approve no-chat agent graph configuration
The LangGraph flow nodes (start_flow, buffer_node, confirming_response_node, reporting_node) and the reduced sleep durations are correctly defined. Streaming config via copilotkit_customize_config and the graph compilation look solid.

Comment on lines +26 to +40
const handleAddStep = () => {
const trimmed = newStep.trim();
if (trimmed.length === 0) return;
setLocalSteps((prevSteps) => [
...prevSteps,
{ description: trimmed, status: "enabled" },
]);
setNewStep("");
};

const handleInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === "Enter") {
handleAddStep();
}
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Move handlers outside the render function for better performance.

Defining handlers inside the render function causes them to be recreated on every render, which can impact performance and potentially cause unnecessary re-renders of child components.

Consider moving these handlers to the component level and using useCallback if needed:

const Chat = () => {
+  const handleAddStep = useCallback(() => {
+    const trimmed = newStep.trim();
+    if (trimmed.length === 0) return;
+    setLocalSteps((prevSteps) => [
+      ...prevSteps,
+      { description: trimmed, status: "enabled" },
+    ]);
+    setNewStep("");
+  }, [newStep]);
+
+  const handleInputKeyDown = useCallback((e: React.KeyboardEvent<HTMLInputElement>) => {
+    if (e.key === "Enter") {
+      handleAddStep();
+    }
+  }, [handleAddStep]);

  useLangGraphInterrupt({
    render: ({ event, resolve }) => {
-      const handleAddStep = () => {
-        // function body
-      };
-
-      const handleInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
-        // function body  
-      };

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In examples/demo-viewer/agent/demo/langgraph_human_in_the_loop/page.tsx around
lines 26 to 40, the event handler functions handleAddStep and handleInputKeyDown
are defined inside the render function, causing them to be recreated on every
render and potentially hurting performance. Move these handlers outside the
render function to the component level and wrap them with React's useCallback
hook to memoize them, ensuring they are only recreated when their dependencies
change.

const Chat = () => {
useLangGraphInterrupt({
render: ({ event, resolve }) => {
const [newStep, setNewStep] = useState("");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Move state declaration outside the render function.

Declaring state inside the render function violates React best practices and can cause performance issues since the state will be recreated on every render.

Consider moving this to the component level or using a ref if the state needs to be scoped to individual render calls:

const Chat = () => {
+  const [newStep, setNewStep] = useState("");
+
  useLangGraphInterrupt({
    render: ({ event, resolve }) => {
-      const [newStep, setNewStep] = useState("");
🤖 Prompt for AI Agents
In examples/demo-viewer/agent/demo/langgraph_human_in_the_loop/page.tsx at line
24, the useState hook is declared inside the render function, which violates
React best practices and can cause performance issues. Move the useState
declaration to the top level of the functional component, outside of the render
logic, so that the state persists across renders and is not recreated each time
the component renders.

Comment on lines 322 to 328
},
{
"name": "page.tsx",
"content": "\"use client\";\r\nimport React, { useState, useEffect } from \"react\";\r\nimport \"@copilotkit/react-ui/styles.css\";\r\nimport \"./style.css\";\r\nimport { CopilotKit, useLangGraphInterrupt } from \"@copilotkit/react-core\";\r\nimport { CopilotChat, useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\r\nimport { initialPrompt, chatSuggestions } from \"@/lib/prompts\";\r\nimport { AGENT_TYPE } from \"@/config\";\r\nconst HumanInTheLoop: React.FC = () => {\r\n return (\r\n <CopilotKit\r\n runtimeUrl={AGENT_TYPE == \"general\" ? \"/api/copilotkit?langgraph=true\" : \"/api/copilotkit\"}\r\n showDevConsole={false}\r\n agent=\"human_in_the_loop\"\r\n >\r\n <Chat />\r\n </CopilotKit>\r\n );\r\n};\r\n\r\nconst Chat = () => {\r\n useLangGraphInterrupt({\r\n render: ({ event, resolve }) => {\r\n\r\n // Ensure we have valid steps data\r\n let initialSteps = [];\r\n if (event.value && event.value.steps && Array.isArray(event.value.steps)) {\r\n initialSteps = event.value.steps.map((step: any) => ({\r\n description: typeof step === 'string' ? step : step.description || '',\r\n status: (typeof step === 'object' && step.status) ? step.status : 'enabled'\r\n }));\r\n }\r\n\r\n const [localSteps, setLocalSteps] = useState<\r\n {\r\n description: string;\r\n status: \"disabled\" | \"enabled\" | \"executing\";\r\n }[]\r\n >(initialSteps);\r\n\r\n const handleCheckboxChange = (index: number) => {\r\n setLocalSteps((prevSteps) =>\r\n prevSteps.map((step, i) =>\r\n i === index\r\n ? {\r\n ...step,\r\n status: step.status === \"enabled\" ? \"disabled\" : \"enabled\",\r\n }\r\n : step\r\n )\r\n );\r\n };\r\n\r\n return (\r\n <div className=\"flex flex-col gap-4 w-[500px] bg-gray-100 rounded-lg p-8 mb-4\">\r\n <div className=\"text-black space-y-2\">\r\n <h2 className=\"text-lg font-bold mb-4\">Select Steps</h2>\r\n {localSteps.map((step, index) => (\r\n <div key={index} className=\"text-sm flex items-center\">\r\n <label className=\"flex items-center cursor-pointer\">\r\n <input\r\n type=\"checkbox\"\r\n checked={step.status === \"enabled\"}\r\n onChange={() => handleCheckboxChange(index)}\r\n className=\"mr-2\"\r\n />\r\n <span\r\n className={\r\n step.status !== \"enabled\" ? \"line-through\" : \"\"\r\n }\r\n >\r\n {step.description}\r\n </span>\r\n </label>\r\n </div>\r\n ))}\r\n <button\r\n className=\"mt-4 bg-gradient-to-r from-purple-400 to-purple-600 text-white py-2 px-4 rounded cursor-pointer w-48 font-bold\"\r\n onClick={() => {\r\n const selectedSteps = localSteps\r\n .filter((step) => step.status === \"enabled\")\r\n .map((step) => step.description);\r\n resolve(\"The user selected the following steps: \" + selectedSteps.join(\", \"));\r\n }}\r\n >\r\n ✨ Perform Steps\r\n </button>\r\n </div>\r\n </div>\r\n );\r\n },\r\n });\r\n useCopilotChatSuggestions({\r\n instructions: chatSuggestions.humanInTheLoop,\r\n })\r\n return (\r\n <div className=\"flex justify-center items-center h-screen w-screen\">\r\n <div className=\"w-8/10 h-8/10\">\r\n <CopilotChat\r\n className=\"h-full rounded-lg\"\r\n labels={{ initial: initialPrompt.humanInTheLoop }}\r\n />\r\n </div>\r\n </div>\r\n );\r\n};\r\n\r\nexport default HumanInTheLoop;\r\n",
"content": "\"use client\";\r\nimport React, { useState, useEffect } from \"react\";\r\nimport \"@copilotkit/react-ui/styles.css\";\r\nimport \"./style.css\";\r\nimport { CopilotKit, useLangGraphInterrupt } from \"@copilotkit/react-core\";\r\nimport { CopilotChat, useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\r\nimport { initialPrompt, chatSuggestions } from \"@/lib/prompts\";\r\nimport { AGENT_TYPE } from \"@/config\";\r\nconst HumanInTheLoop: React.FC = () => {\r\n return (\r\n <CopilotKit\r\n runtimeUrl={AGENT_TYPE == \"general\" ? \"/api/copilotkit?langgraph=true\" : \"/api/copilotkit\"}\r\n showDevConsole={false}\r\n agent=\"human_in_the_loop\"\r\n >\r\n <Chat />\r\n </CopilotKit>\r\n );\r\n};\r\n\r\nconst Chat = () => {\r\n useLangGraphInterrupt({\r\n render: ({ event, resolve }) => {\r\n const [newStep, setNewStep] = useState(\"\");\r\n\r\n const handleAddStep = () => {\r\n const trimmed = newStep.trim();\r\n if (trimmed.length === 0) return;\r\n setLocalSteps((prevSteps) => [\r\n ...prevSteps,\r\n { description: trimmed, status: \"enabled\" },\r\n ]);\r\n setNewStep(\"\");\r\n };\r\n\r\n const handleInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n if (e.key === \"Enter\") {\r\n handleAddStep();\r\n }\r\n };\r\n // Ensure we have valid steps data\r\n let initialSteps = [];\r\n if (event.value && event.value.steps && Array.isArray(event.value.steps)) {\r\n initialSteps = event.value.steps.map((step: any) => ({\r\n description: typeof step === 'string' ? step : step.description || '',\r\n status: (typeof step === 'object' && step.status) ? step.status : 'enabled'\r\n }));\r\n }\r\n\r\n const [localSteps, setLocalSteps] = useState<\r\n {\r\n description: string;\r\n status: \"disabled\" | \"enabled\" | \"executing\";\r\n }[]\r\n >(initialSteps);\r\n\r\n const handleCheckboxChange = (index: number) => {\r\n setLocalSteps((prevSteps) =>\r\n prevSteps.map((step, i) =>\r\n i === index\r\n ? {\r\n ...step,\r\n status: step.status === \"enabled\" ? \"disabled\" : \"enabled\",\r\n }\r\n : step\r\n )\r\n );\r\n };\r\n\r\n return (\r\n <div className=\"flex flex-col gap-4 w-[500px] bg-gray-100 rounded-lg p-8 mb-4\">\r\n <div className=\"text-black space-y-2\">\r\n <h2 className=\"text-lg font-bold mb-4\">Select Steps</h2>\r\n {localSteps.map((step, index) => (\r\n <div key={index} className=\"text-sm flex items-center\">\r\n <label className=\"flex items-center cursor-pointer\">\r\n <input\r\n type=\"checkbox\"\r\n checked={step.status === \"enabled\"}\r\n onChange={() => handleCheckboxChange(index)}\r\n className=\"mr-2\"\r\n />\r\n <span\r\n className={\r\n step.status !== \"enabled\" ? \"line-through\" : \"\"\r\n }\r\n >\r\n {step.description}\r\n </span>\r\n </label>\r\n </div>\r\n ))}\r\n <div className=\"flex items-center gap-2 mb-4\">\r\n <input\r\n type=\"text\"\r\n className=\"flex-1 rounded py-2 focus:outline-none\"\r\n placeholder=\"Add a new step...\"\r\n value={newStep}\r\n onChange={(e) => setNewStep(e.target.value)}\r\n onKeyDown={handleInputKeyDown}\r\n // hidden={status != \"executing\"}\r\n />\r\n </div>\r\n <button\r\n className=\"mt-4 bg-gradient-to-r from-purple-400 to-purple-600 text-white py-2 px-4 rounded cursor-pointer w-48 font-bold\"\r\n onClick={() => {\r\n const selectedSteps = localSteps\r\n .filter((step) => step.status === \"enabled\")\r\n .map((step) => step.description);\r\n resolve(\"The user selected the following steps: \" + selectedSteps.join(\", \"));\r\n }}\r\n >\r\n ✨ Perform Steps\r\n </button>\r\n </div>\r\n </div>\r\n );\r\n },\r\n });\r\n useCopilotChatSuggestions({\r\n instructions: chatSuggestions.humanInTheLoop,\r\n })\r\n return (\r\n <div className=\"flex justify-center items-center h-screen w-screen\">\r\n <div className=\"w-8/10 h-8/10\">\r\n <CopilotChat\r\n className=\"h-full rounded-lg\"\r\n labels={{ initial: initialPrompt.humanInTheLoop }}\r\n />\r\n </div>\r\n </div>\r\n );\r\n};\r\n\r\nexport default HumanInTheLoop;\r\n",
"path": "langgraph_human_in_the_loop\\page.tsx",
"language": "typescript",
"type": "file"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Critical: Re-enable step-input hiding in LangGraph HIL
The hidden prop for the <input> is commented out, causing the new-step input to be always visible—even when the component isn’t executing. Re-enable and use the status prop to conditionally hide the field.

Apply this diff:

-                // hidden={status != "executing"}
+                hidden={status !== "executing"}

Optionally, hoist all useState calls (including for localSteps) to the top of the render callback to adhere to the Rules of Hooks.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In examples/demo-viewer/src/files.json around lines 322 to 328, the input field
for adding new steps has its hidden prop commented out, causing it to always be
visible regardless of the component's execution status. To fix this, uncomment
and use the hidden prop on the input element, setting it to true when status is
not "executing" to conditionally hide the input. Additionally, move all useState
hooks, including the one for localSteps, to the top of the render function to
comply with React's Rules of Hooks.

Comment on lines 539 to 545
"files": [
{
"name": "page.tsx",
"content": "\"use client\";\r\nimport React, { useState, useEffect } from \"react\";\r\nimport \"@copilotkit/react-ui/styles.css\";\r\nimport \"./style.css\";\r\nimport { CopilotKit, useCopilotAction, useLangGraphInterrupt } from \"@copilotkit/react-core\";\r\nimport { CopilotChat, useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\r\nimport { initialPrompt, chatSuggestions, instructions } from \"@/lib/prompts\";\r\nconst HumanInTheLoop: React.FC = () => {\r\n return (\r\n <CopilotKit\r\n runtimeUrl=\"/api/copilotkit?standard=true\"\r\n showDevConsole={false}\r\n >\r\n <Chat />\r\n </CopilotKit>\r\n );\r\n};\r\n\r\nconst Chat = () => {\r\n\r\n useCopilotAction({\r\n name: \"generate_task_steps\",\r\n description: \"Make up 10 steps (only a couple of words per step) that are required for a task. The step should be in imperative form (i.e. Dig hole, Open door, ...). When the user responds with selected steps, you must generate the summary with the selected steps.\",\r\n parameters: [\r\n {\r\n type: \"object[]\",\r\n name: \"items\",\r\n description: \"An array of 10 step objects, each containing text and status\",\r\n attributes: [\r\n {\r\n type: \"string\",\r\n name: \"description\",\r\n description: \"The text of the step in imperative form\"\r\n },\r\n {\r\n type: \"string\",\r\n name: \"status\",\r\n description: \"The status of the step, always 'enabled'\"\r\n }\r\n ]\r\n }\r\n ],\r\n renderAndWaitForResponse: ({ args, respond, status }) => {\r\n useEffect(() => {\r\n console.log(args, \"args.steps\")\r\n setLocalSteps(args?.items || [])\r\n }, [args])\r\n const [localSteps, setLocalSteps] = useState<\r\n {\r\n description: string;\r\n status: string;\r\n }[]\r\n >(args?.items || [])\r\n const handleCheckboxChange = (index: number) => {\r\n debugger\r\n const newSteps = [...localSteps];\r\n newSteps[index].status = newSteps[index].status === \"enabled\" ? \"disabled\" : \"enabled\";\r\n setLocalSteps(newSteps);\r\n };\r\n return (localSteps) ? <div className=\"flex flex-col gap-4 w-[500px] bg-gray-100 rounded-lg p-8 mb-4\">\r\n <div className=\"text-black space-y-2\">\r\n <h2 className=\"text-lg font-bold mb-4\">Select Steps</h2>\r\n {localSteps.map((step: any, index: number) => (\r\n <div key={index} className=\"text-sm flex items-center\">\r\n <label className=\"flex items-center cursor-pointer\">\r\n <input\r\n type=\"checkbox\"\r\n checked={step.status == \"enabled\"}\r\n onChange={() => {\r\n if (respond) {\r\n handleCheckboxChange(index)\r\n }\r\n }}\r\n className=\"mr-2\"\r\n />\r\n <span\r\n className={\r\n step.status !== \"enabled\" ? \"line-through\" : \"\"\r\n }\r\n >\r\n {step.description}\r\n </span>\r\n </label>\r\n </div>\r\n ))}\r\n <button\r\n className=\"mt-4 bg-gradient-to-r from-purple-400 to-purple-600 text-white py-2 px-4 rounded cursor-pointer w-48 font-bold\"\r\n hidden={!respond}\r\n onClick={() => {\r\n if (respond) {\r\n console.log(`The user has selected the following steps: ${localSteps.filter((step) => step.status === \"enabled\").map((step) => step.description).join(\", \")}`)\r\n respond(`The user has selected the following steps: ${localSteps.filter((step) => step.status === \"enabled\").map((step) => step.description).join(\", \")}`)\r\n }\r\n }}\r\n >\r\n ✨ Perform Steps\r\n </button>\r\n </div>\r\n </div> : <></>\r\n }\r\n })\r\n\r\n\r\n useCopilotChatSuggestions({\r\n instructions: chatSuggestions.humanInTheLoop,\r\n })\r\n return (\r\n <div className=\"flex justify-center items-center h-screen w-screen\">\r\n <div className=\"w-8/10 h-8/10\">\r\n <CopilotChat\r\n className=\"h-full rounded-lg\"\r\n labels={{ initial: initialPrompt.humanInTheLoop }}\r\n instructions={instructions.humanInTheLoop}\r\n />\r\n </div>\r\n </div>\r\n );\r\n};\r\n\r\nexport default HumanInTheLoop;\r\n",
"content": "\"use client\";\r\nimport React, { useState, useEffect } from \"react\";\r\nimport \"@copilotkit/react-ui/styles.css\";\r\nimport \"./style.css\";\r\nimport { CopilotKit, useCopilotAction, useLangGraphInterrupt } from \"@copilotkit/react-core\";\r\nimport { CopilotChat, useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\r\nimport { initialPrompt, chatSuggestions, instructions } from \"@/lib/prompts\";\r\nconst HumanInTheLoop: React.FC = () => {\r\n return (\r\n <CopilotKit\r\n runtimeUrl=\"/api/copilotkit?standard=true\"\r\n showDevConsole={false}\r\n >\r\n <Chat />\r\n </CopilotKit>\r\n );\r\n};\r\n\r\nconst Chat = () => {\r\n\r\n useCopilotAction({\r\n name: \"generate_task_steps\",\r\n description: \"Make up 10 steps (only a couple of words per step) that are required for a task. The step should be in imperative form (i.e. Dig hole, Open door, ...). When the user responds with selected steps, you must generate the summary with the selected steps.\",\r\n parameters: [\r\n {\r\n type: \"object[]\",\r\n name: \"items\",\r\n description: \"An array of 10 step objects, each containing text and status\",\r\n attributes: [\r\n {\r\n type: \"string\",\r\n name: \"description\",\r\n description: \"The text of the step in imperative form\"\r\n },\r\n {\r\n type: \"string\",\r\n name: \"status\",\r\n description: \"The status of the step, always 'enabled'\"\r\n }\r\n ]\r\n }\r\n ],\r\n renderAndWaitForResponse: ({ args, respond, status }) => {\r\n const [newStep, setNewStep] = useState(\"\");\r\n\r\n const handleAddStep = () => {\r\n const trimmed = newStep.trim();\r\n if (trimmed.length === 0) return;\r\n setLocalSteps((prevSteps) => [\r\n ...prevSteps,\r\n { description: trimmed, status: \"enabled\" },\r\n ]);\r\n setNewStep(\"\");\r\n };\r\n\r\n const handleInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n if (e.key === \"Enter\") {\r\n handleAddStep();\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n console.log(args, \"args.steps\")\r\n setLocalSteps(args?.items || [])\r\n }, [args])\r\n const [localSteps, setLocalSteps] = useState<\r\n {\r\n description: string;\r\n status: string;\r\n }[]\r\n >(args?.items || [])\r\n const handleCheckboxChange = (index: number) => {\r\n debugger\r\n const newSteps = [...localSteps];\r\n newSteps[index].status = newSteps[index].status === \"enabled\" ? \"disabled\" : \"enabled\";\r\n setLocalSteps(newSteps);\r\n };\r\n return (localSteps) ? <div className=\"flex flex-col gap-4 w-[500px] bg-gray-100 rounded-lg p-8 mb-4\">\r\n <div className=\"text-black space-y-2\">\r\n <h2 className=\"text-lg font-bold mb-4\">Select Steps</h2>\r\n {localSteps.map((step: any, index: number) => (\r\n <div key={index} className=\"text-sm flex items-center\">\r\n <label className=\"flex items-center cursor-pointer\">\r\n <input\r\n type=\"checkbox\"\r\n checked={step.status == \"enabled\"}\r\n onChange={() => {\r\n if (respond) {\r\n handleCheckboxChange(index)\r\n }\r\n }}\r\n className=\"mr-2\"\r\n />\r\n <span\r\n className={\r\n step.status !== \"enabled\" ? \"line-through\" : \"\"\r\n }\r\n >\r\n {step.description}\r\n </span>\r\n </label>\r\n </div>\r\n ))}\r\n <div className=\"flex items-center gap-2 mb-4\">\r\n <input\r\n type=\"text\"\r\n className=\"flex-1 rounded py-2 focus:outline-none\"\r\n placeholder=\"Add a new step...\"\r\n value={newStep}\r\n onChange={(e) => setNewStep(e.target.value)}\r\n onKeyDown={handleInputKeyDown}\r\n hidden={status != \"executing\"}\r\n />\r\n </div>\r\n <button\r\n className=\"mt-4 bg-gradient-to-r from-purple-400 to-purple-600 text-white py-2 px-4 rounded cursor-pointer w-48 font-bold\"\r\n hidden={!respond}\r\n onClick={() => {\r\n if (respond) {\r\n console.log(`The user has selected the following steps: ${localSteps.filter((step) => step.status === \"enabled\").map((step) => step.description).join(\", \")}`)\r\n respond(`The user has selected the following steps: ${localSteps.filter((step) => step.status === \"enabled\").map((step) => step.description).join(\", \")}`)\r\n }\r\n }}\r\n >\r\n ✨ Perform Steps\r\n </button>\r\n </div>\r\n </div> : <></>\r\n }\r\n })\r\n\r\n\r\n useCopilotChatSuggestions({\r\n instructions: chatSuggestions.humanInTheLoop,\r\n })\r\n return (\r\n <div className=\"flex justify-center items-center h-screen w-screen\">\r\n <div className=\"w-8/10 h-8/10\">\r\n <CopilotChat\r\n className=\"h-full rounded-lg\"\r\n labels={{ initial: initialPrompt.humanInTheLoop }}\r\n instructions={instructions.humanInTheLoop}\r\n />\r\n </div>\r\n </div>\r\n );\r\n};\r\n\r\nexport default HumanInTheLoop;\r\n",
"path": "standard_human_in_the_loop\\page.tsx",
"language": "typescript",
"type": "file"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Critical: Remove leftover debugger and correct logging/conditional rendering in Standard HIL
A debugger statement remains in handleCheckboxChange, and the console log labels args.steps instead of args.items. Also, localSteps (always truthy) is used for the render guard, so the UI shows even when there are no items.

Proposed fix:

       const handleCheckboxChange = (index: number) => {
-        debugger
+        // debugger removed for production
         const newSteps = [...localSteps];
         newSteps[index].status = newSteps[index].status === "enabled" ? "disabled" : "enabled";
         setLocalSteps(newSteps);
       };

       useEffect(() => {
-        console.log(args, "args.steps")
+        console.log(args, "args.items")
         setLocalSteps(args?.items || [])
       }, [args]);

-      return (localSteps) ? <div className="flex flex-col gap-4 ..."> ... 
+      return (args?.items?.length > 0) ? <div className="flex flex-col gap-4 ..."> ... 
🤖 Prompt for AI Agents
In examples/demo-viewer/src/files.json around lines 539 to 545, remove the
leftover debugger statement inside the handleCheckboxChange function. Change the
console.log label from "args.steps" to "args.items" to correctly reflect the
logged data. Replace the render guard condition from simply checking localSteps
(which is always truthy) to checking if localSteps has any items (e.g.,
localSteps.length > 0) to prevent rendering the UI when there are no steps.

…create_agents function and directly initialized the CopilotKitSDK with the LangGraph agent, simplifying the code structure.
@changesets-bot-copilotkit

Copy link
Copy Markdown

⏭️ Changeset Not Required

Latest commit: 5d9370a

No changes in this PR affected the @copilitkit/* packages. Merging this PR will not cause a version bump for any packages.

Changeset is not required for this PR.

@github-actions

github-actions Bot commented Jun 5, 2025 •

Copy link
Copy Markdown
Contributor

Preview environments destroyed for this pull request.

@github-actions

github-actions Bot commented Jun 5, 2025 •

Copy link
Copy Markdown
Contributor

Test Results

Status: ✅ Passed (View Run)

Commit: 7a0a1bc

Duration: 385.5s

Total Tests: 32

Pass Rate: 100.0%

Failed Tests: 0

🔍 Detailed Results

coagents-research-canvas

CoAgents Research Canvas (UI) - Local Depenencies

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
CrewAI chromium ✅ PASSED -
OpenAI (LGC Python in-memory) chromium ✅ PASSED -
Anthropic (LGC Python in-memory) chromium ✅ PASSED -
OpenAI (LGC JS in-memory) chromium ✅ PASSED -
Anthropic (LGC JS in-memory) chromium ✅ PASSED -

coagents-qa-native

CoAgents QA Native (UI) - Local

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
OpenAI (LGC Python) chromium ✅ PASSED -
Anthropic (LGC Python) chromium ✅ PASSED -
OpenAI (LGC JS) chromium ✅ PASSED -
Anthropic (LGC JS) chromium ✅ PASSED -

coagents-qa-text

CoAgents QA Text (UI) - Local

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
OpenAI (LGC Python) chromium ✅ PASSED -
Anthropic (LGC Python) chromium ✅ PASSED -
OpenAI (LGC JS) chromium ✅ PASSED -
Anthropic (LGC JS) chromium ✅ PASSED -

coagents-routing

CoAgents Routing (UI) - Local

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
OpenAI (LGC Python) chromium ✅ PASSED -
Anthropic (LGC Python) chromium ✅ PASSED -
OpenAI (LGC JS) chromium ✅ PASSED -
Anthropic (LGC JS) chromium ✅ PASSED -

next-openai

Next OpenAI - Self Hosted

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
Google Generative AI chromium ✅ PASSED -
LangChain (OpenAI) chromium ✅ PASSED -
LangChain (Anthropic) chromium ✅ PASSED -
LangChain (Gemini) chromium ✅ PASSED -
Groq chromium ✅ PASSED -

@copilotkit-support
copilotkit-support merged commit c1db09e into main Jun 5, 2025
@copilotkit-support
copilotkit-support deleted the CPK-2442-HITL-option-2-add-new-items branch June 5, 2025 12:12
suhasdeshpande added a commit that referenced this pull request Jun 5, 2025
@copilotkit-support
copilotkit-support restored the CPK-2442-HITL-option-2-add-new-items branch June 6, 2025 07:25
@coderabbitai coderabbitai Bot mentioned this pull request Jun 6, 2025
2 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Aug 1, 2025
2 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Oct 13, 2025
2 tasks done

This branch was successfully deployed

14 active deployments
Production – demo-viewer — 5d9370a7 Deployed Jun 6, 2025 by vercel[bot]
Preview – docs — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Preview – examples-coagents-research-canvas-ui — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Preview – examples-coagents-ai-travel-app — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Preview – copilotkit-mastra-feature-viewer — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Preview – ag2-starter — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Preview – copilot-mastra-starter — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Preview – coagents-starter-crewai-flows — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Preview – ag2-feature-viewer — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Preview – copilot-kit — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Preview – copilot-kit-wq8x — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Preview – copilotkit-feature-viewer — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Preview – demo-viewer — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Preview – copilot-kit-qd8p — 5d9370a7 Deployed Jun 5, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant