dify/api/services/workflow
Yansong Zhang 66212e3575 feat(api): implement zero-migration transparent upgrade (Phase 8)
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
2026-04-09 10:30:52 +08:00
..
__init__.py FEAT: NEW WORKFLOW ENGINE (#3160) 2024-04-08 18:51:46 +08:00
entities.py feat: Human Input Node (#32060) 2026-02-09 14:57:23 +08:00
graph_factory.py feat(api): add Agent V2 node and new Agent app type (Phase 1-3) 2026-04-08 12:31:23 +08:00
nested_node_graph_service.py feat(api): enable all sandbox/skill controller routes and resolve dependencies (P0) 2026-04-09 09:36:16 +08:00
queue_dispatcher.py feat: trigger billing (#28335) 2025-11-20 10:15:23 +08:00
scheduler.py feat: introduce trigger functionality (#27644) 2025-11-12 17:59:37 +08:00
virtual_workflow.py feat(api): implement zero-migration transparent upgrade (Phase 8) 2026-04-09 10:30:52 +08:00
workflow_converter.py refactor: convert AppMode if/elif to match/case in service files (#30001) (#34562) 2026-04-05 10:22:11 +00:00