diff --git a/app/(chat)/api/chat/route.ts b/app/(chat)/api/chat/route.ts index 3801635a8..3298aa96b 100644 --- a/app/(chat)/api/chat/route.ts +++ b/app/(chat)/api/chat/route.ts @@ -3884,6 +3884,16 @@ export async function POST(request: Request) { .trim(); const autoContextText = typeof autoContext === "string" ? autoContext.trim() : ""; + if (composerMode === "agent" && !agentPresetId) { + return NextResponse.json( + { + code: "bad_request:api", + message: "智能体模式缺少生图模式配置,请刷新页面后重新选择生图模式再试", + }, + { status: 400 }, + ); + } + const now = Date.now(); for (const [key, startedAt] of inFlightChatRequests.entries()) { if (now - startedAt > IN_FLIGHT_REQUEST_TTL_MS) { diff --git a/components/agents/AgentGenerationWorkspaceDarkV2.tsx b/components/agents/AgentGenerationWorkspaceDarkV2.tsx index 2cb4892d9..81fea7aca 100644 --- a/components/agents/AgentGenerationWorkspaceDarkV2.tsx +++ b/components/agents/AgentGenerationWorkspaceDarkV2.tsx @@ -1081,8 +1081,12 @@ export function AgentGenerationWorkspaceDarkV2({ hiddenPrompt: hiddenPromptRef.current || undefined, agentPresetId: transportState.selectedAgentPresetId || selectedAgentPresetId || undefined, - selectedChatModel: transportState.selectedModelId, - composerMode: "agent" as const, + selectedChatModel: + transportState.selectedModelId !== "auto" + ? transportState.selectedModelId + : selectedAgentPreset?.defaultModelId || transportState.selectedModelId, + composerMode: + selectedAgentPreset?.type === "image" ? ("image" as const) : ("agent" as const), selectedVisibilityType: "private", imageParams: transportState.imageParams, contextPayload: { diff --git a/components/agents/AgentGenerationWorkspaceNew.tsx b/components/agents/AgentGenerationWorkspaceNew.tsx index 815595ef3..b9a316c29 100644 --- a/components/agents/AgentGenerationWorkspaceNew.tsx +++ b/components/agents/AgentGenerationWorkspaceNew.tsx @@ -365,8 +365,12 @@ export function AgentGenerationWorkspaceNew({ hiddenPrompt: hiddenPromptRef.current || undefined, agentPresetId: transportState.selectedAgentPresetId || selectedAgentPresetId || undefined, - selectedChatModel: transportState.selectedModelId, - composerMode: "agent" as const, + selectedChatModel: + transportState.selectedModelId !== "auto" + ? transportState.selectedModelId + : selectedAgentPreset?.defaultModelId || transportState.selectedModelId, + composerMode: + selectedAgentPreset?.type === "image" ? ("image" as const) : ("agent" as const), selectedVisibilityType: "private", imageParams: transportState.imageParams, contextPayload: {