Skip to content

Conversation

@yujiosaka
Copy link

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

Fixes #28140

This PR enables the Agent node to recognize attached files in chatflows, aligning its behavior with the LLM node.

Screenshots

Screenshot 2025-12-25 at 23 40 04
Before After
No Vision option in Agent node Vision option with Set Variables and Resolution settings
Files in Query/Instruction not recognized Files properly recognized and sent to LLM

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

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. 🤖 feat:agent Agent related topics labels Dec 25, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yujiosaka, 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 significantly enhances the Agent node's ability to interact with and utilize files within chatflows. By enabling the Agent node to recognize and process attached files, it aligns its behavior with the existing LLM node, allowing for more versatile and powerful agent-based applications. The changes include both backend logic for file parsing and frontend UI updates to expose these new configuration options to users.

Highlights

  • Agent Node File Recognition: The Agent node can now recognize and process attached files within chatflows, bringing its capabilities in line with the LLM node.
  • Vision Configuration for Agent Node: A new VisionConfig has been introduced for the Agent node, allowing users to enable and configure vision-related settings, including variable selectors for files and image detail resolution.
  • Enhanced Query and Instruction Handling: The Agent node's query and instruction parameters now correctly parse and convert various file types (image, video, audio, document) into prompt message content for the underlying models.
  • Frontend UI Update: The Agent node panel in the web interface has been updated to include the new vision configuration options, providing a user-friendly way to manage file recognition settings.
  • Comprehensive Unit Tests: New unit tests have been added to thoroughly validate the file handling logic within the Agent node, covering scenarios with text, files, and combinations thereof, as well as ensuring unsupported file types are ignored.

🧠 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.

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.

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

This pull request adds file recognition capabilities to the Agent node, aligning it with the LLM node's functionality. The changes look good overall, introducing vision configuration on both the backend and frontend, and adding corresponding tests.

I have a couple of suggestions:

  • In api/core/workflow/nodes/agent/agent_node.py, there's an opportunity to refactor some duplicated code for handling file segments to improve maintainability.
  • The new tests in api/tests/unit_tests/core/workflow/nodes/agent/test_agent_node.py could be improved by testing the node's method directly rather than re-implementing its logic, which would make them more robust.

Apart from these points, the implementation is solid and the changes are well-structured.

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Dec 25, 2025
@yujiosaka yujiosaka changed the title Agent node file recognition fix: agent node file recognition Dec 28, 2025
Resolved conflicts by migrating nodes.agent.vision translation key from
deleted workflow.ts files to the new workflow.json format with proper
translations for each locale.
@yujiosaka yujiosaka force-pushed the fix/agent-node-file-recognition branch from 1192fbf to f9aaf4f Compare December 30, 2025 06:41
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Dec 30, 2025
… directly

Address Gemini Code Assist High Priority review comment:
- Refactor tests to call actual _generate_agent_parameters method instead of
  re-implementing the logic
- Move imports to top of file (using fixture pattern to handle circular imports)
- Tests now properly instantiate AgentNode, prepare inputs, call the method,
  and assert the returned dict is correct
- Add new test case for for_log parameter behavior
- Add new test case for non-query/instruction parameters
Address Gemini Code Assist Medium Priority review comment:
- Combine ArrayFileSegment and FileSegment handling logic to reduce code
  duplication
- Use isinstance check with tuple to handle both segment types in a single
  branch
- Extract files list conditionally based on segment type
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 feat:agent Agent related topics size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent node (with vision-enabled LLM) not recognizing image

1 participant