dify icon indicating copy to clipboard operation
dify copied to clipboard

feat: implement Agent V2 node with enhanced file handling and direct implementation

Open Nov1c444 opened this issue 2 months ago • 1 comments

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
  • [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

Nov1c444 avatar Oct 10 '25 09:10 Nov1c444

Noice!

fdb02983rhy avatar Oct 17 '25 09:10 fdb02983rhy