Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(agent-v2): stop dropping non-vision attachments from agent chat (#40179)
chelsealongd813edb945ff
diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/chat.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/chat.spec.tsxindex 308bd5a2761..2b8c2647aea 100644--- a/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/chat.spec.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/chat.spec.tsx@@ -1,6 +1,7 @@import type { ComponentProps, ReactNode } from 'react'import type { AgentPreviewChatController } from '../chat-conversation'import type { AgentChatRuntimeEmptyStateProps } from '../chat-runtime'+import type { FileEntity } from '@/app/components/base/file-uploader/types'import type { SpeechToTextTarget } from '@/app/components/base/voice-input/types'import type { AgentSoulConfigFormState } from '@/features/agent-v2/agent-composer/form-state'import { toast } from '@langgenius/dify-ui/toast'@@ -57,7 +58,7 @@ vi.mock('@/next/dynamic', async () => {default: () =>function MockChat(props: {answerActionPosition?: 'auto' | 'below'- onSend: (message: string) => unknown+ onSend: (message: string, files?: FileEntity[]) => unknownonStopResponding: () => voidsendButtonLabel?: stringsendButtonLoading?: boolean@@ -113,6 +114,26 @@ vi.mock('@/next/dynamic', async () => {>send</button>+ <button+ type="button"+ onClick={() => {+ setSent(true)+ sendResultRef.current = props.onSend('read this file', [+ {+ id: 'file-1',+ name: 'brief.docx',+ size: 1024,+ type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',+ progress: 100,+ transferMethod: TransferMethod.local_file,+ supportFileType: 'document',+ uploadedId: 'uploaded-file-1',+ },+ ])+ }}+ >+ send with document+ </button><button type="button" onClick={props.onStopResponding}>stop</button>@@ -720,6 +741,21 @@ describe('AgentPreviewChat', () => {)})+ it('should deliver non-image attachments even when the selected model does not support vision', async () => {+ renderPreviewChat()++ fireEvent.click(screen.getByRole('button', { name: 'send with document' }))++ await waitFor(() => expect(handleSendMock).toHaveBeenCalledTimes(1))+ expect(handleSendMock).toHaveBeenCalledWith(+ 'agent/agent-1/chat-messages',+ expect.objectContaining({+ files: [expect.objectContaining({ id: 'file-1', name: 'brief.docx' })],+ }),+ expect.any(Object),+ )+ })+it('should save draft before sending preview chat through the agent chat endpoints', async () => {const saveDraftBeforeRun = vi.fn().mockResolvedValue(undefined)renderPreviewChat({diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/chat-conversation.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/chat-conversation.tsxindex 9f6ea73931f..7e24e51af51 100644--- a/web/features/agent-v2/agent-detail/configure/components/preview/chat-conversation.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/preview/chat-conversation.tsx@@ -19,13 +19,11 @@ import { useTranslation } from 'react-i18next'import { AgentRosterResponseContent } from '@/app/components/base/chat/chat/answer/agent-roster-response-content'import { useChat } from '@/app/components/base/chat/chat/hooks'import { getLastAnswer, isValidGeneratedAnswer } from '@/app/components/base/chat/utils'-import { ModelFeatureEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'-import { useTextGenerationCurrentProviderAndModelAndModelList } from '@/app/components/header/account-setting/model-provider-page/hooks'import { useDocLink } from '@/context/i18n'import { userProfileQueryOptions } from '@/features/account-profile/client'import dynamic from '@/next/dynamic'import { consoleClient, consoleQuery } from '@/service/client'-import { buildChatConfig, getAgentSoulInputs, getAgentSoulInputsForm } from './chat-config'+import { getAgentSoulInputs, getAgentSoulInputsForm } from './chat-config'const Chat = dynamic(() => import('@/app/components/base/chat/chat'), { ssr: false })@@ -79,7 +77,7 @@ export function AgentPreviewChatConversation({clearChatList,config,conversationId,- currentModel,+ currentModel: _currentModel,draftType,initialChatTree,inputs,@@ -135,8 +133,6 @@ export function AgentPreviewChatConversation({sendInterruptedRef.current = trueonSendInterrupted?.()}, [onSendInterrupted])- const { textGenerationModelList } =- useTextGenerationCurrentProviderAndModelAndModelList(currentModel)const {chatList,setTargetMessageId,@@ -178,21 +174,6 @@ export function AgentPreviewChatConversation({const runtimeInputs = preparedAgentSoulConfig? getAgentSoulInputs(runtimeInputsForm): inputs- const runtimeConfig = preparedAgentSoulConfig- ? buildChatConfig({- agentSoulConfig: runtimeAgentSoulConfig,- currentModel: undefined,- prompt: runtimeAgentSoulConfig?.prompt?.system_prompt ?? '',- })- : config-- const currentProvider = textGenerationModelList.find(- (item) => item.provider === runtimeConfig.model.provider,- )- const selectedModel = currentProvider?.models.find(- (model) => model.model === runtimeConfig.model.name,- )- const supportVision = selectedModel?.features?.includes(ModelFeatureEnum.vision)const data: Record<string, unknown> = {query: message,inputs: runtimeInputs,@@ -202,7 +183,7 @@ export function AgentPreviewChatConversation({}if (draftType) data.draft_type = draftType- if (files?.length && supportVision) data.files = files+ if (files?.length) data.files = filessendMessage({agentId,@@ -280,7 +261,6 @@ export function AgentPreviewChatConversation({agentId,agentSoulConfig,chatList,- config,conversationId,draftType,docLink,@@ -295,7 +275,6 @@ export function AgentPreviewChatConversation({queryClient,sendMessage,t,- textGenerationModelList,],)