Repository navigation
Revert "Cpk 2442 hitl option 2 add new items" - #1938
Conversation
This reverts commit c1db09e.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
⏭️ Changeset Not RequiredLatest commit: 051bee3 No changes in this PR affected the Changeset is not required for this PR. |
WalkthroughThis change removes the ability to add new steps via text input in several human-in-the-loop demo React components. It also refactors related agent logic and updates prompt instructions, focusing on simplifying the UI and improving code structure without altering primary control flows or exported entity signatures. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant StepsFeedbackComponent
participant Agent
User->>StepsFeedbackComponent: View steps (no add-step input)
StepsFeedbackComponent->>User: Display existing steps with toggles
User->>StepsFeedbackComponent: Toggle steps, click "Perform Steps"
StepsFeedbackComponent->>Agent: Send selected steps
Agent->>StepsFeedbackComponent: Continue flow
Possibly related PRs
Suggested labels
Suggested reviewers
✨ 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: 1
🧹 Nitpick comments (2)
examples/demo-viewer/agent/demo/langgraph_server.py (2)
26-68: Remove or utilize the unusedcontextparameter.The
create_agentsfunction accepts acontextparameter but doesn't use it anywhere in the function body. This could confuse other developers about the intended purpose of this parameter.Consider one of these approaches:
-def create_agents(context): +def create_agents():Or if the context parameter is intended for future use, add a comment explaining its purpose:
def create_agents(context): + # TODO: Use context parameter for environment-specific agent configuration return [
70-72: Consider migrating from deprecated CopilotKitSDK.The
CopilotKitSDKclass is deprecated since version 0.1.31 and emits deprecation warnings. Consider migrating toCopilotKitRemoteEndpointfor better long-term maintenance.-from copilotkit import CopilotKitSDK, LangGraphAgent +from copilotkit import CopilotKitRemoteEndpoint, LangGraphAgent -sdk = CopilotKitSDK( +sdk = CopilotKitRemoteEndpoint( agents=create_agents )
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
examples/demo-viewer/agent/demo/crewai_human_in_the_loop/page.tsx(0 hunks)examples/demo-viewer/agent/demo/langgraph_human_in_the_loop/page.tsx(0 hunks)examples/demo-viewer/agent/demo/langgraph_server.py(2 hunks)examples/demo-viewer/agent/demo/standard_human_in_the_loop/page.tsx(0 hunks)examples/demo-viewer/src/files.json(4 hunks)examples/demo-viewer/src/lib/prompts.ts(1 hunks)
💤 Files with no reviewable changes (3)
- examples/demo-viewer/agent/demo/langgraph_human_in_the_loop/page.tsx
- examples/demo-viewer/agent/demo/standard_human_in_the_loop/page.tsx
- examples/demo-viewer/agent/demo/crewai_human_in_the_loop/page.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
examples/demo-viewer/agent/demo/langgraph_server.py (1)
sdk-python/copilotkit/sdk.py (1)
CopilotKitSDK(391-401)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- 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, agent, python, local-deps)
- GitHub Check: Build Images (coagents-qa-native, agent, python, local-deps)
- GitHub Check: Build Images (coagents-routing, agent, python, local-deps)
- GitHub Check: Build Images (coagents-qa-native, ui)
- GitHub Check: Build Images (coagents-routing, ui)
- GitHub Check: Build Images (coagents-research-canvas, ui)
🔇 Additional comments (4)
examples/demo-viewer/src/lib/prompts.ts (1)
50-50:Details
✅ Verification successful
Verify consistency of revert across the codebase.
The instruction text modification appears correct and aligns with removing user-added step functionality. However, since this revert affects multiple components according to the AI summary, ensure all related references have been consistently removed.
🏁 Script executed:
#!/bin/bash # Description: Verify that all references to user-added steps functionality have been consistently removed across the codebase # Expected: No remaining references to user adding steps or related functionality echo "Searching for any remaining references to user-added steps functionality..." # Search for patterns related to user adding steps rg -i "user.*add.*step" --type ts --type tsx --type js --type jsx -A 2 -B 2 # Search for "While summarizing" patterns that might have been missed rg -i "while summarizing" --type ts --type tsx --type js --type jsx -A 2 -B 2 # Search for text input related to steps rg -i "text.*input.*step|step.*text.*input" --type ts --type tsx --type js --type jsx -A 2 -B 2 # Check for any TODO or FIXME comments related to this revert rg -i "todo|fixme" --type ts --type tsx --type js --type jsx | rg -i "step|add|input" -A 1 -B 1Length of output: 626
To account for the
rgsandbox’s lack of built-intsx/jsxtypes, let’s rerun without type filters but restrict by file glob:
🏁 Script executed:
#!/bin/bash echo "Re-running search across .ts, .tsx, .js, .jsx files..." # Look for any remaining references to user-added step functionality rg -i "user.*add.*step" -g "*.ts*" -g "*.js*" -A2 -B2 # Look for stray “while summarizing” fragments rg -i "while summarizing" -g "*.ts*" -g "*.js*" -A2 -B2 # Look for text-input related to steps rg -i "text.*input.*step|step.*text.*input" -g "*.ts*" -g "*.js*" -A2 -B2 # Check for any TODO/FIXME around step/add/input rg -i "todo|fixme" -g "*.ts*" -g "*.js*" | rg -i "step|add|input" -A2 -B2Length of output: 71845
Revert consistency verified – no lingering user‐added step references.
I searched across all
.ts,.tsx,.js, and.jsxfiles for patterns like “user…add…step”, “while summarizing”, text‐input step references, and related TODO/FIXME comments and found nothing. The human-in-the-loop prompt update aligns cleanly with the broader revert. No further changes needed.examples/demo-viewer/src/files.json (3)
76-80: Revert human-in-the-loop input removal correctly
Thecrewai_human_in_the_loop/page.tsxentry’s content no longer includes a text input for adding new steps—only the checkbox flow remains, which aligns with the PR’s revert objective. The JSON snippet is well-formed and matches the updated file layout.
324-328: Approve robust LangGraph HIL interruption code
Thelanggraph_human_in_the_loop/page.tsxentry has been updated to useuseLangGraphInterrupt, with proper runtime checks and mapping ofevent.value.stepsinto a local state. The inline React component cleanly handles toggling and resolution of selected steps.
484-495: No changes in the no-chat agent entries
Thelanggraph_no_chat/agent.pyand its associatedpage.tsxJSON objects are re-listed but not functionally altered by this revert. Everything remains consistent with the existing no-chat agent implementation.
| "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", | ||
| "path": "standard_human_in_the_loop\\page.tsx", | ||
| "language": "typescript", | ||
| "type": "file" |
There was a problem hiding this comment.
Fix stray debugger and incorrect log in standard HIL
Inside the renderAndWaitForResponse callback for standard_human_in_the_loop/page.tsx, there’s a leftover debugger statement and a console.log labeling the wrong property (args.steps instead of args.items). These will break or confuse runtime behavior.
Apply this diff:
- const handleCheckboxChange = (index: number) => {
- debugger
- const newSteps = [...localSteps];
+ const handleCheckboxChange = (index: number) => {
+ const newSteps = [...localSteps];- useEffect(() => {
- console.log(args, "args.steps")
+ useEffect(() => {
+ console.log(args, "args.items")
setLocalSteps(args?.items || [])
}, [args])📝 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.
| "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", | |
| "path": "standard_human_in_the_loop\\page.tsx", | |
| "language": "typescript", | |
| "type": "file" | |
| useEffect(() => { | |
| console.log(args, "args.items") | |
| setLocalSteps(args?.items || []) | |
| }, [args]) | |
| const handleCheckboxChange = (index: number) => { | |
| const newSteps = [...localSteps]; | |
| newSteps[index].status = newSteps[index].status === "enabled" ? "disabled" : "enabled"; | |
| setLocalSteps(newSteps); | |
| }; |
🤖 Prompt for AI Agents
In examples/demo-viewer/src/files.json around lines 542 to 545, remove the stray
debugger statement inside the renderAndWaitForResponse callback in
standard_human_in_the_loop/page.tsx, and update the console.log to correctly
reference args.items instead of args.steps to prevent runtime issues and
confusion.
|
Preview environments destroyed for this pull request. |
Test ResultsStatus: ✅ Passed (View Run) Commit: d365b28 Duration: 378.7s Total Tests: 32 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
|
Reverts #1934
Summary by CodeRabbit
Bug Fixes
Refactor
Style