Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion backend/services/agent_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ async def get_creating_sub_agent_info_impl(authorization: str = Header(None)):
f"Failed to get sub agent enable tool id list: {str(e)}")

return {"agent_id": sub_agent_id,
"name": agent_info.get("name"),
"display_name": agent_info.get("display_name"),
"description": agent_info.get("description"),
"enable_tool_id_list": enable_tool_id_list,
"model_name": agent_info["model_name"],
"max_steps": agent_info["max_steps"],
Expand Down Expand Up @@ -598,7 +601,7 @@ async def list_all_agent_info_impl(tenant_id: str) -> list[dict]:
simple_agent_list = []
for agent in agent_list:
# check agent is available
if not agent["name"]:
if not agent["enabled"]:
continue
tool_info = search_tools_for_sub_agent(
agent_id=agent["agent_id"], tenant_id=tenant_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ export default function AgentSetupOrchestrator({
};

const fetchSubAgentIdAndEnableToolList = async (t: TFunction) => {
setIsLoadingTools(true);
// Clear the tool selection status when loading starts
setSelectedTools([]);
setEnabledToolIds([]);
setIsLoadingTools(false);

try {
const result = await getCreatingSubAgentId();
if (result.success && result.data) {
const {
agentId,
name,
displayName,
description,
enabledToolIds,
modelName,
maxSteps,
Expand All @@ -142,6 +142,12 @@ export default function AgentSetupOrchestrator({

// Update the main agent ID
setMainAgentId(agentId);
// Update the main agent name
setAgentName?.(name);
// Update the main agent display name
setAgentDisplayName?.(displayName);
// Update the main agent description
setAgentDescription?.(description);
// Update the enabled tool ID list
setEnabledToolIds(enabledToolIds);
// Update the enabled agent ID list from sub_agent_id_list
Expand Down
110 changes: 8 additions & 102 deletions frontend/app/[locale]/setup/agentSetup/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { AGENT_SETUP_LAYOUT_DEFAULT, GENERATE_PROMPT_STREAM_TYPES } from "@/cons
import { SETUP_PAGE_CONTAINER, STANDARD_CARD } from "@/const/layoutConstants";
import { OpenAIModel } from "@/types/modelConfig";
import {
NewAgentCache,
LayoutConfig,
AgentConfigDataResponse,
AgentConfigCustomEvent,
Expand Down Expand Up @@ -64,17 +63,6 @@ export default function AgentConfig() {
const [agentDescription, setAgentDescription] = useState("");
const [agentDisplayName, setAgentDisplayName] = useState("");

// Add cache for new agent creation to preserve content when switching controllers
const [newAgentCache, setNewAgentCache] = useState<NewAgentCache>({
businessLogic: "",
dutyContent: "",
constraintContent: "",
fewShotsContent: "",
agentName: "",
agentDescription: "",
agentDisplayName: "",
});

// Add state for business logic and action buttons
const [isGeneratingAgent, setIsGeneratingAgent] = useState(false);

Expand Down Expand Up @@ -350,25 +338,6 @@ export default function AgentConfig() {
};
}, [businessLogic, dutyContent, constraintContent, fewShotsContent]);

// Remove frontend caching logic, completely rely on backend returned sub_agent_id_list
// No longer need to set selectedAgents based on enabledAgentIds

// Monitor the status change of creating a new agent, and reset the relevant status
useEffect(() => {
if (isCreatingNewAgent) {
// When starting to create new agent, try to restore cached content
restoreNewAgentContent();
}

// Always reset these states regardless of creation mode
setSelectedTools([]);

// Reset the main agent configuration related status
if (!isCreatingNewAgent) {
setMainAgentModel(OpenAIModel.MainModel);
setMainAgentMaxStep(5);
}
}, [isCreatingNewAgent]);

const handleEditingStateChange = (isEditing: boolean, agent: any) => {
setIsEditingAgent(isEditing);
Expand All @@ -378,23 +347,7 @@ export default function AgentConfig() {
if (isEditing && agent) {
setAgentName(agent.name || "");
setAgentDescription(agent.description || "");
// If creating new agent, cache current content first, then clear
if (isCreatingNewAgent) {
setNewAgentCache({
businessLogic,
dutyContent,
constraintContent,
fewShotsContent,
agentName,
agentDescription,
agentDisplayName,
});
// Clear new creation related content
setIsCreatingNewAgent(false);
setDutyContent("");
setConstraintContent("");
setFewShotsContent("");
}

} else if (!isEditing) {
// When stopping editing, clear name description box
setAgentName("");
Expand All @@ -410,41 +363,9 @@ export default function AgentConfig() {
return mainAgentId ? parseInt(mainAgentId) : undefined;
};

const restoreNewAgentContent = () => {
if (
newAgentCache.businessLogic ||
newAgentCache.dutyContent ||
newAgentCache.constraintContent ||
newAgentCache.fewShotsContent ||
newAgentCache.agentName ||
newAgentCache.agentDescription
) {
setBusinessLogic(newAgentCache.businessLogic);
setDutyContent(newAgentCache.dutyContent);
setConstraintContent(newAgentCache.constraintContent);
setFewShotsContent(newAgentCache.fewShotsContent);
setAgentName(newAgentCache.agentName);
setAgentDescription(newAgentCache.agentDescription);
setAgentDisplayName(newAgentCache.agentDisplayName);
}
};

const clearNewAgentCache = () => {
setNewAgentCache({
businessLogic: "",
dutyContent: "",
constraintContent: "",
fewShotsContent: "",
agentName: "",
agentDescription: "",
agentDisplayName: "",
});
};

// Handle exit creation mode - should clear cache
const handleExitCreation = () => {
setIsCreatingNewAgent(false);
clearNewAgentCache();
setBusinessLogic("");
setDutyContent("");
setConstraintContent("");
Expand Down Expand Up @@ -491,10 +412,7 @@ export default function AgentConfig() {
setBusinessLogic={(value) => {
setBusinessLogic(value);
if (isCreatingNewAgent) {
setNewAgentCache((prev) => ({
...prev,
businessLogic: value,
}));
setBusinessLogic(value);
}
}}
selectedTools={selectedTools}
Expand All @@ -519,54 +437,42 @@ export default function AgentConfig() {
setDutyContent={(value) => {
setDutyContent(value);
if (isCreatingNewAgent) {
setNewAgentCache((prev) => ({ ...prev, dutyContent: value }));
setDutyContent(value);
}
}}
constraintContent={constraintContent}
setConstraintContent={(value) => {
setConstraintContent(value);
if (isCreatingNewAgent) {
setNewAgentCache((prev) => ({
...prev,
constraintContent: value,
}));
setConstraintContent(value);
}
}}
fewShotsContent={fewShotsContent}
setFewShotsContent={(value) => {
setFewShotsContent(value);
if (isCreatingNewAgent) {
setNewAgentCache((prev) => ({
...prev,
fewShotsContent: value,
}));
setFewShotsContent(value);
}
}}
agentName={agentName}
setAgentName={(value) => {
setAgentName(value);
if (isCreatingNewAgent) {
setNewAgentCache((prev) => ({ ...prev, agentName: value }));
setAgentName(value);
}
}}
agentDescription={agentDescription}
setAgentDescription={(value) => {
setAgentDescription(value);
if (isCreatingNewAgent) {
setNewAgentCache((prev) => ({
...prev,
agentDescription: value,
}));
setAgentDescription(value);
}
}}
agentDisplayName={agentDisplayName}
setAgentDisplayName={(value) => {
setAgentDisplayName(value);
if (isCreatingNewAgent) {
setNewAgentCache((prev) => ({
...prev,
agentDisplayName: value,
}));
setAgentDisplayName(value);
}
}}
isGeneratingAgent={isGeneratingAgent}
Expand Down
3 changes: 3 additions & 0 deletions frontend/services/agentConfigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export const getCreatingSubAgentId = async () => {
success: true,
data: {
agentId: data.agent_id,
name: data.name,
displayName: data.display_name,
description: data.description,
enabledToolIds: data.enable_tool_id_list || [],
modelName: data.model_name,
maxSteps: data.max_steps,
Expand Down
11 changes: 0 additions & 11 deletions frontend/types/agentConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ export interface ToolParam {

// ========== Data Interfaces ==========

// Agent creation cache interface
export interface NewAgentCache {
businessLogic: string;
dutyContent: string;
constraintContent: string;
fewShotsContent: string;
agentName: string;
agentDescription: string;
agentDisplayName: string;
}

// Agent configuration data response interface
export interface AgentConfigDataResponse {
businessLogic: string;
Expand Down
Loading