[PR #26718] feat: implement Agent V2 node with enhanced file handling and direct implementation #31527

Open
opened 2026-02-21 20:49:38 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/26718

State: open
Merged: No


Summary

This PR introduces Agent V2, a new implementation of agent functionality in Dify workflows with significant improvements over V1.

close #18812

Key Features

1. Enhanced File Handling

  • Multi-modal Support: Files can now be transferred between tools and models
  • Flexible File Input: Files can be passed via vision field (for vision-enabled models) or via prompt (for model/tool processing)
  • Tool-Model File Exchange: Enables complex workflows where tools generate files that can be consumed by models and vice versa

2. Plugin-free Architecture

  • Direct Implementation: Removes the plugin system dependency from V1
  • Better Performance: Eliminates plugin overhead and communication layers
  • Simplified Deployment: No need to manage external plugin processes
  • Improved Reliability: Fewer moving parts mean fewer potential failure points

3. Unified Architecture

  • Shared Agent Patterns: Leverages a common module used by both Agent nodes and Agent applications
  • Consistent Behavior: Ensures same execution logic across different agent implementations
  • Code Reuse: Reduces duplication between Agent APP and workflow agents

Technical Implementation

  • Agent Patterns Module (api/core/agent/patterns/): Core execution strategies

    • base.py: Abstract interface for all strategies
    • function_call.py: Native tool calling implementation
    • react.py: ReAct prompting implementation
    • strategy_factory.py: Strategy selection based on model features
  • Agent V2 Node (api/core/workflow/nodes/agent/v2/): Workflow integration

    • Full LLM node compatibility (prompt templates, memory, vision, context)
    • Support for all tool types (builtin, API, MCP, workflow, plugin)
    • Standard workflow error handling and retry mechanisms

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/26718 **State:** open **Merged:** No --- ## Summary This PR introduces Agent V2, a new implementation of agent functionality in Dify workflows with significant improvements over V1. close #18812 ## Key Features ### 1. Enhanced File Handling - **Multi-modal Support**: Files can now be transferred between tools and models - **Flexible File Input**: Files can be passed via vision field (for vision-enabled models) or via prompt (for model/tool processing) - **Tool-Model File Exchange**: Enables complex workflows where tools generate files that can be consumed by models and vice versa ### 2. Plugin-free Architecture - **Direct Implementation**: Removes the plugin system dependency from V1 - **Better Performance**: Eliminates plugin overhead and communication layers - **Simplified Deployment**: No need to manage external plugin processes - **Improved Reliability**: Fewer moving parts mean fewer potential failure points ### 3. Unified Architecture - **Shared Agent Patterns**: Leverages a common module used by both Agent nodes and Agent applications - **Consistent Behavior**: Ensures same execution logic across different agent implementations - **Code Reuse**: Reduces duplication between Agent APP and workflow agents ## Technical Implementation - **Agent Patterns Module** (`api/core/agent/patterns/`): Core execution strategies - `base.py`: Abstract interface for all strategies - `function_call.py`: Native tool calling implementation - `react.py`: ReAct prompting implementation - `strategy_factory.py`: Strategy selection based on model features - **Agent V2 Node** (`api/core/workflow/nodes/agent/v2/`): Workflow integration - Full LLM node compatibility (prompt templates, memory, vision, context) - Support for all tool types (builtin, API, MCP, workflow, plugin) - Standard workflow error handling and retry mechanisms ## Screenshots | Before | After | |--------|-------| | ... | ... | ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:49:38 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31527