mirror of
https://github.com/langgenius/dify.git
synced 2026-07-15 01:17:04 +08:00
Add two feature-flag-controlled upgrade paths that allow existing apps and LLM nodes to transparently run through the Agent V2 engine without any database migration: 1. AGENT_V2_TRANSPARENT_UPGRADE (default: off): When enabled, old apps (chat/completion/agent-chat) bypass legacy Easy-UI runners. VirtualWorkflowSynthesizer converts AppModelConfig to an in-memory Workflow (start -> agent-v2 -> answer) at runtime, then executes via AdvancedChatAppGenerator. Falls back to legacy path on any synthesis error. VirtualWorkflowSynthesizer maps: - model JSON -> ModelConfig - pre_prompt/chat_prompt_config -> prompt_template - agent_mode.tools -> ToolMetadata[] - agent_mode.strategy -> agent_strategy - dataset_configs -> context - file_upload -> vision 2. AGENT_V2_REPLACES_LLM (default: off): When enabled, DifyNodeFactory.create_node() transparently remaps nodes with type="llm" to type="agent-v2" before class resolution. Since AgentV2NodeData is a strict superset of LLMNodeData, the mapping is lossless. With tools=[], Agent V2 behaves identically to LLM Node. Both flags default to False for safety. Turn off = instant rollback. 46 existing tests pass. Flask starts successfully. Made-with: Cursor