Skip to content

chore: move agent node back to core/workflows/nodes#33338

Open
fatelei wants to merge 1 commit intolanggenius:mainfrom
fatelei:issue-33335
Open

chore: move agent node back to core/workflows/nodes#33338
fatelei wants to merge 1 commit intolanggenius:mainfrom
fatelei:issue-33335

Conversation

@fatelei
Copy link
Contributor

@fatelei fatelei commented Mar 12, 2026

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

fix #33335

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 make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

Copilot AI review requested due to automatic review settings March 12, 2026 01:59
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 12, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on a significant refactoring effort to relocate the agent node's core implementation and related components within the project's directory structure. The primary goal is to enhance code maintainability and logical grouping by moving these files into the core/workflow/nodes path, ensuring that all dependencies and references are correctly updated to reflect this change.

Highlights

  • Code Refactoring: The agent node module and its associated files have been refactored and moved from dify_graph/nodes/agent to core/workflow/nodes/agent to improve code organization.
  • Import Path Updates: All relevant import statements across the codebase, including those for AgentMaxIterationError, AgentNode, and AgentNodeData, have been updated to reflect the new module location.
  • Test File Adjustments: Unit tests have been updated to correctly import the AgentNode from its new path, ensuring continued test coverage for the refactored module.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • api/core/agent/cot_agent_runner.py
    • Updated import path for AgentMaxIterationError.
  • api/core/agent/fc_agent_runner.py
    • Updated import path for AgentMaxIterationError.
  • api/dify_graph/nodes/agent/init.py
    • Renamed to api/core/workflow/nodes/agent/__init__.py.
  • api/dify_graph/nodes/agent/agent_node.py
    • Renamed to api/core/workflow/nodes/agent/agent_node.py.
    • Updated internal imports for agent node entities.
  • api/dify_graph/nodes/agent/entities.py
    • Renamed to api/core/workflow/nodes/agent/entities.py.
  • api/dify_graph/nodes/agent/exc.py
    • Renamed to api/core/workflow/nodes/agent/exc.py.
  • api/dify_graph/nodes/base/node.py
    • Updated import paths for AgentNode and AgentNodeData.
  • api/tests/unit_tests/core/workflow/graph_engine/test_mock_nodes.py
    • Updated import path for AgentNode.
Activity
  • No specific activity (comments, reviews, progress) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Contributor

Pyrefly Diff

No changes detected.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request refactors the project structure by relocating agent-related modules and classes, including AgentMaxIterationError, AgentNodeData, AgentOldVersionModelFeatures, ParamsAutoGenerated, and AgentNode, from the dify_graph.nodes.agent package to core.workflow.nodes.agent. This change involves updating import statements across multiple files such as cot_agent_runner.py, fc_agent_runner.py, agent_node.py, node.py, and test_mock_nodes.py to reflect the new module paths.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the workflow Agent node location by moving it back under core/workflow/nodes/agent and updating call sites/imports to use the new module path across runtime code and tests.

Changes:

  • Update imports to reference core.workflow.nodes.agent.AgentNode instead of the previous dify_graph location.
  • Add core.workflow.nodes.agent package modules (agent_node support types/exceptions and package export).
  • Update agent runners to import the relocated AgentMaxIterationError.

Reviewed changes

Copilot reviewed 5 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
api/tests/unit_tests/core/workflow/graph_engine/test_mock_nodes.py Switches mock node test imports to the relocated AgentNode.
api/dify_graph/nodes/base/node.py Updates AgentNode/AgentNodeData imports used when constructing node start events.
api/core/workflow/nodes/agent/exc.py Introduces Agent-node-specific exception types under the new package.
api/core/workflow/nodes/agent/entities.py Introduces Agent node Pydantic entities/types under the new package.
api/core/workflow/nodes/agent/agent_node.py Updates imports to use the new in-package entities module.
api/core/workflow/nodes/agent/init.py Exports AgentNode from the new package.
api/core/agent/fc_agent_runner.py Updates AgentMaxIterationError import path.
api/core/agent/cot_agent_runner.py Updates AgentMaxIterationError import path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Mar 12, 2026
@github-actions
Copy link
Contributor

Pyrefly Diff

No changes detected.

Copilot AI review requested due to automatic review settings March 12, 2026 09:08
@github-actions
Copy link
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-12 09:10:03.721269381 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-12 09:09:55.133274863 +0000
@@ -483,8 +483,10 @@
    --> dify_graph/graph_engine/layers/execution_limits.py:141:81
 ERROR Object of class `GraphExecutionProtocol` has no attribute `node_executions` [missing-attribute]
    --> dify_graph/nodes/base/node.py:331:31
+ERROR Argument `Any | None` is not assignable to parameter `name` with type `bytearray | bytes | str` in function `dify_graph.entities.agent.AgentNodeStrategyInit.__init__` [bad-argument-type]
+   --> dify_graph/nodes/base/node.py:392:22
 ERROR `str` is not assignable to attribute `id` with type `Never` [bad-assignment]
-   --> dify_graph/nodes/base/node.py:414:32
+   --> dify_graph/nodes/base/node.py:413:32
 ERROR Object of class `BaseOxmlElement` has no attribute `body` [missing-attribute]
    --> dify_graph/nodes/document_extractor/node.py:446:19
 ERROR `+` is not supported between `list[Unknown]` and `str` [unsupported-operation]

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 12 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-12 09:13:38.146402071 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-12 09:13:28.061382214 +0000
@@ -484,7 +484,7 @@
 ERROR Object of class `GraphExecutionProtocol` has no attribute `node_executions` [missing-attribute]
    --> dify_graph/nodes/base/node.py:331:31
 ERROR `str` is not assignable to attribute `id` with type `Never` [bad-assignment]
-   --> dify_graph/nodes/base/node.py:414:32
+   --> dify_graph/nodes/base/node.py:413:32
 ERROR Object of class `BaseOxmlElement` has no attribute `body` [missing-attribute]
    --> dify_graph/nodes/document_extractor/node.py:446:19
 ERROR `+` is not supported between `list[Unknown]` and `str` [unsupported-operation]

@github-actions
Copy link
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-12 09:17:24.566171518 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-12 09:17:15.337101135 +0000
@@ -484,7 +484,7 @@
 ERROR Object of class `GraphExecutionProtocol` has no attribute `node_executions` [missing-attribute]
    --> dify_graph/nodes/base/node.py:331:31
 ERROR `str` is not assignable to attribute `id` with type `Never` [bad-assignment]
-   --> dify_graph/nodes/base/node.py:414:32
+   --> dify_graph/nodes/base/node.py:413:32
 ERROR Object of class `BaseOxmlElement` has no attribute `body` [missing-attribute]
    --> dify_graph/nodes/document_extractor/node.py:446:19
 ERROR `+` is not supported between `list[Unknown]` and `str` [unsupported-operation]

Copilot AI review requested due to automatic review settings March 12, 2026 13:56
@github-actions
Copy link
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-12 13:58:25.675503164 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-12 13:58:16.763482684 +0000
@@ -484,7 +484,7 @@
 ERROR Object of class `GraphExecutionProtocol` has no attribute `node_executions` [missing-attribute]
    --> dify_graph/nodes/base/node.py:331:31
 ERROR `str` is not assignable to attribute `id` with type `Never` [bad-assignment]
-   --> dify_graph/nodes/base/node.py:414:32
+   --> dify_graph/nodes/base/node.py:413:32
 ERROR Object of class `BaseOxmlElement` has no attribute `body` [missing-attribute]
    --> dify_graph/nodes/document_extractor/node.py:446:19
 ERROR `+` is not supported between `list[Unknown]` and `str` [unsupported-operation]

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 12 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor/Chore] move agent node back to core/workflows/nodes

3 participants