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
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ export default function AgentGenerateDetail({
model_id: defaultLlmModel.id || 0,
});
}
// Sync max_step to store in create mode (default to 5)
if (isCreatingMode && !editedAgent.max_step) {
updateProfileInfo({ max_step: 5 });
}
// Sync author to store if not already set (e.g., in create mode with default user email)
const defaultAuthor = editedAgent.author || user?.email || (isSpeedMode ? "Default User" : "");
if (!editedAgent.author && defaultAuthor) {
Expand Down
22 changes: 21 additions & 1 deletion frontend/hooks/agent/useSaveGuard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { App } from "antd";
import { useQueryClient } from "@tanstack/react-query";
import { useConfirmModal } from "../useConfirmModal";
import { useAgentConfigStore } from "@/stores/agentConfigStore";
import { updateAgentInfo, updateToolConfig, searchToolConfig } from "@/services/agentConfigService";
import { updateAgentInfo, updateToolConfig, searchToolConfig, searchAgentInfo } from "@/services/agentConfigService";
import { Agent } from "@/types/agentConfig";
import log from "@/lib/logger";

Expand Down Expand Up @@ -152,11 +152,31 @@ export const useSaveGuard = () => {
);

// Get the final agent ID (from result for new agents, existing currentAgentId for updates)
const isCreatingMode = useAgentConfigStore.getState().isCreatingMode;
const finalAgentId = result.data?.agent_id || currentAgentId;
if (!finalAgentId) {
throw new Error("Failed to get agent ID after save operation");
}

// Handle create mode: exit create mode and select the newly created agent
if (isCreatingMode) {
try {
// Load the full agent details
const agentDetailResult = await searchAgentInfo(Number(finalAgentId));
if (agentDetailResult.success && agentDetailResult.data) {
// Exit create mode and set the newly created agent as current
useAgentConfigStore.getState().setCurrentAgent({
...agentDetailResult.data,
permission: "EDIT",
});
}
} catch (error) {
log.error("Failed to load newly created agent details:", error);
// Still exit create mode even if detail loading fails
useAgentConfigStore.getState().setCurrentAgent(null);
}
}

// Batch process tool configurations for both create and update modes
const baselineTools = useAgentConfigStore.getState().baselineAgent?.tools || [];
await batchUpdateToolConfigs(finalAgentId, currentEditedAgent.tools || [], baselineTools);
Expand Down
Loading