[PR #30796] feat: Support displaying non-image tool files in agent runs #32963

Closed
opened 2026-02-21 20:52:24 -05:00 by yindo · 0 comments
Owner

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

State: closed
Merged: No


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 #30795

  • This PR delivers a minimal viable improvement to surface non-image files produced by tools during agent runs.
  • On the web, to minimize impact, I intentionally reuse and extend the existing VisionFile shape instead of introducing a new type. In the future, we can unify on FileResponse for a cleaner model and broader refactor.

Changes:

  • Backend:
    • Enrich message_file stream events with additional metadata (upload_file_id, transfer_method, mime_type, filename, size, related_id, extension) to support non-image files.
    • Extend tool engine handling for BINARY_LINK so non-image outputs with mime types are captured and persisted as MessageFile entries.
  • Frontend:
    • Extend VisionFile with optional fields (mime_type, filename, size, related_id, extension) to consume the enriched stream event with minimal Web impact.

Compatibility:

  • The message_file event remains unchanged in shape for existing consumers; new fields are additive and optional on the frontend.
  • Preserves historical data paths: when ToolFile metadata is unavailable, sensible defaults are provided, ensuring the UI continues to function.

Testing:

  • Verified single-file and multi-file scenarios, including historical messages, to ensure no regressions.
  • Confirmed streaming behavior and rendering work for non-image files (e.g., .pptx, .docx, .pdf) and that image handling remains unaffected.

Future Work:

  • Consider unifying frontend file handling on FileResponse to reduce duplication and improve consistency across views.

Screenshots

Before After
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
**Original Pull Request:** https://github.com/langgenius/dify/pull/30796 **State:** closed **Merged:** No --- > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 1. Ensure there is an associated issue and you have been assigned to it > 1. Use the correct syntax to link this PR: `Fixes #<issue number>`. ## Summary Fixes #30795 - This PR delivers a minimal viable improvement to surface non-image files produced by tools during agent runs. - On the web, to minimize impact, I intentionally reuse and extend the existing `VisionFile` shape instead of introducing a new type. In the future, we can unify on `FileResponse` for a cleaner model and broader refactor. ### Changes: - Backend: - Enrich `message_file` stream events with additional metadata (upload_file_id, transfer_method, mime_type, filename, size, related_id, extension) to support non-image files. - Extend tool engine handling for `BINARY_LINK` so non-image outputs with mime types are captured and persisted as `MessageFile` entries. - Frontend: - Extend `VisionFile` with optional fields (mime_type, filename, size, related_id, extension) to consume the enriched stream event with minimal Web impact. ### Compatibility: - The `message_file` event remains unchanged in shape for existing consumers; new fields are additive and optional on the frontend. - Preserves historical data paths: when `ToolFile `metadata is unavailable, sensible defaults are provided, ensuring the UI continues to function. ### Testing: - Verified single-file and multi-file scenarios, including historical messages, to ensure no regressions. - Confirmed streaming behavior and rendering work for non-image files (e.g., .pptx, .docx, .pdf) and that image handling remains unaffected. ### Future Work: - Consider unifying frontend file handling on `FileResponse` to reduce duplication and improve consistency across views. ## Screenshots | Before | After | |--------|-------| | <img width="282" height="196" alt="before" src="https://github.com/user-attachments/assets/490088f8-6083-41f7-a146-1fc1595a0141" />| <img width="330" height="200" alt="after" src="https://github.com/user-attachments/assets/1e57c393-0b73-44d8-952e-63098e6c5216" /> | ## 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 `make lint` and `make type-check` (backend) and `cd web && npx lint-staged` (frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:52:24 -05:00
yindo closed this issue 2026-02-21 20:52:24 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32963