Remove retain as control type from task agents (internal)

This commit is contained in:
akhisud3195 2025-07-11 16:11:39 +05:30
parent 21a7bc64ff
commit 173dd9142f

View file

@ -10,7 +10,6 @@ import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Select, Selec
import { PreviewModalProvider } from "../workflow/preview-modal"; import { PreviewModalProvider } from "../workflow/preview-modal";
import { CopilotMessage } from "@/app/lib/types/copilot_types"; import { CopilotMessage } from "@/app/lib/types/copilot_types";
import { getCopilotAgentInstructions } from "@/app/actions/copilot_actions"; import { getCopilotAgentInstructions } from "@/app/actions/copilot_actions";
import { Dropdown, DropdownTrigger, DropdownMenu, DropdownItem } from "@heroui/react";
import { Dropdown as CustomDropdown } from "../../../lib/components/dropdown"; import { Dropdown as CustomDropdown } from "../../../lib/components/dropdown";
import { createAtMentions } from "../../../lib/components/atmentions"; import { createAtMentions } from "../../../lib/components/atmentions";
import { Textarea } from "@/components/ui/textarea"; import { Textarea } from "@/components/ui/textarea";
@ -110,12 +109,16 @@ export function AgentConfig({
setShowRagCta(false); setShowRagCta(false);
}; };
// Add effect to handle control type update when transfer control is disabled // Add effect to handle control type update when transfer control is disabled or when internal agents have invalid control type
useEffect(() => { useEffect(() => {
if (!USE_TRANSFER_CONTROL_OPTIONS && agent.controlType !== 'retain') { if (!USE_TRANSFER_CONTROL_OPTIONS && agent.controlType !== 'retain') {
handleUpdate({ ...agent, controlType: 'retain' }); handleUpdate({ ...agent, controlType: 'retain' });
} }
}, [agent.controlType, agent, handleUpdate]); // For internal agents, "retain" is not a valid option, so change it to "relinquish_to_parent"
if (agent.outputVisibility === "internal" && agent.controlType === 'retain') {
handleUpdate({ ...agent, controlType: 'relinquish_to_parent' });
}
}, [agent.controlType, agent.outputVisibility, agent, handleUpdate]);
// Add effect to handle escape key // Add effect to handle escape key
useEffect(() => { useEffect(() => {
@ -610,11 +613,18 @@ export function AgentConfig({
</label> </label>
<CustomDropdown <CustomDropdown
value={agent.controlType} value={agent.controlType}
options={[ options={
{ key: "retain", label: "Retain control" }, agent.outputVisibility === "internal"
{ key: "relinquish_to_parent", label: "Relinquish to parent" }, ? [
{ key: "relinquish_to_start", label: "Relinquish to 'start' agent" } { key: "relinquish_to_parent", label: "Relinquish to parent" },
]} { key: "relinquish_to_start", label: "Relinquish to 'start' agent" }
]
: [
{ key: "retain", label: "Retain control" },
{ key: "relinquish_to_parent", label: "Relinquish to parent" },
{ key: "relinquish_to_start", label: "Relinquish to 'start' agent" }
]
}
onChange={(value) => handleUpdate({ onChange={(value) => handleUpdate({
...agent, ...agent,
controlType: value as z.infer<typeof WorkflowAgent>['controlType'] controlType: value as z.infer<typeof WorkflowAgent>['controlType']