dify/api/core/tools
Yansong Zhang 96641a93f6 feat(api): add Agent V2 node and new Agent app type (Phase 1-3)
Introduce a new unified Agent V2 workflow node that combines LLM capabilities
with agent tool-calling loops, along with a new AppMode.AGENT for standalone
agent apps backed by single-node workflows.

Phase 1 — Agent Patterns:
- Add core/agent/patterns/ module (AgentPattern, FunctionCallStrategy,
  ReActStrategy, StrategyFactory) ported from feat/support-agent-sandbox
- Add ExecutionContext, AgentLog, AgentResult entities
- Add Tool.to_prompt_message_tool() for LLM-consumable tool conversion

Phase 2 — Agent V2 Workflow Node:
- Add core/workflow/nodes/agent_v2/ (AgentV2Node, AgentV2NodeData,
  AgentV2ToolManager, AgentV2EventAdapter)
- Register agent-v2 node type in DifyNodeFactory
- No-tools path: single LLM call (LLM Node equivalent)
- Tools path: FC/ReAct loop via StrategyFactory

Phase 3 — Agent App Type:
- Add AppMode.AGENT to model enum
- Add WorkflowGraphFactory for auto-generating start->agent_v2->answer graphs
- AppService.create_app() creates workflow draft for AGENT mode
- AppGenerateService.generate() routes AGENT to AdvancedChatAppGenerator
- Console API and DSL import/export support AGENT mode
- Default app template for AGENT mode

Old agent/agent-chat/LLM node paths are fully preserved.
38 unit tests all passing.

Made-with: Cursor
2026-04-08 12:31:23 +08:00
..
__base feat(api): add Agent V2 node and new Agent app type (Phase 1-3) 2026-04-08 12:31:23 +08:00
builtin_tool refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
custom_tool refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
entities refactor(api): tighten types for Tenant.custom_config_dict and MCPToolProvider.headers (#34698) 2026-04-08 01:36:42 +00:00
mcp_tool refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
plugin_tool chore: use from __future__ import annotations (#30254) 2026-01-06 23:57:20 +09:00
utils refactor(api): tighten types for Tenant.custom_config_dict and MCPToolProvider.headers (#34698) 2026-04-08 01:36:42 +00:00
workflow_as_tool refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
__init__.py improve: generalize tool parameter converter (#4786) 2024-06-03 21:26:58 +08:00
errors.py feat: Human Input Node (#32060) 2026-02-09 14:57:23 +08:00
signature.py refactor(api): continue decoupling dify_graph from API concerns (#33580) 2026-03-25 20:32:24 +08:00
tool_engine.py refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
tool_file_manager.py refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
tool_label_manager.py refactor: core/tools, agent, callback_handler, encrypter, llm_generator, plugin, inner_api (#34205) 2026-03-28 10:14:43 +00:00
tool_manager.py refactor(api): tighten types for Tenant.custom_config_dict and MCPToolProvider.headers (#34698) 2026-04-08 01:36:42 +00:00