Skip to content

The file transfer logic in the workflow orchestration page is inconsistent with that of external API calls. #41169

Closed

Description

@lb20021008

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.16.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

1.Create a workflow that takes a URL as input and outputs an image description.
2.Register this tool in the new version of the agent.
3.Register the workflow as a tool
4.Provide a sample URL for testing in new agent.

✔️ Expected Behavior

The vision model receives the image in the workflow, processes it, and generates an image description.

❌ Actual Behavior

The model cannot access the image and therefore fails to parse it, but it works fine when test-run within the workflow orchestration page.

Activity

  1. dosubot commented on Aug 24, 2026

    @dosubot

    @lb20021008 This is a confirmed bug in the Agent node's FunctionCalling strategy plugin that affects Dify 1.16.1. The behavior you're seeing — works in the workflow test panel but fails when the workflow is called as a tool from the agent — stems from a gap in how files are propagated to the agent strategy.

    Root cause: The function_calling.yaml plugin doesn't declare a files parameter, so sys.files from the current turn is never passed into the strategy. The current user message is always constructed as text-only (UserPromptMessage(content=self.query)), which means the image is invisible to the model on the first turn. It only becomes visible on the second turn because by then the image exists in conversation history. [1]

    The LLM node (and the workflow test runner) works fine because it uses a different code path that directly injects the file into the prompt without going through the agent strategy plugin. [2]

    This is tracked in dify-official-plugins#2888 — a community contributor has tested a proof-of-concept fix (adding an optional files parameter to the plugin), but no fix has been merged yet. [1]

    Additionally, there's a separate frontend issue in chat-conversation.tsx where if (files?.length && supportVision) data.files = files silently drops all file attachments when the selected model doesn't advertise vision support. [3] If your agent's model isn't flagged as vision-capable, files may never even reach the backend.

    Workaround: Place an LLM node (with vision enabled) before the Agent node to describe the image as text, then pass that text description into the Agent as a string variable. This sidesteps the file propagation gap entirely. [2]

    Could you share whether:

    • The URL you're passing is a remote_url or a Dify-hosted upload?
    • What model/provider you're using for the vision step inside the workflow?

    That would help confirm whether this is purely the agent-strategy file propagation bug or also involves the frontend file-dropping issue.

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about dify with Dosu

  2. lb20021008 commented on Aug 24, 2026

    @lb20021008
    Author

    @dosu I will provide several images as supporting evidence.

    First, I used a plugin that downloads images via an input URL. Its input looks like this:

    {
    "image_url": "https://picsum.photos/seed/42/800/600"
    }

    And its output looks like this:

    {
    "text": "Image '600.jpg' downloaded successfully",
    "files": [
    {
    "dify_model_identity": "dify__file",
    "id": null,
    "type": "image",
    "transfer_method": "tool_file",
    "remote_url": null,
    "reference": "dify-file-ref:eyJyZWNvcmRfaWQiOiI5NDFjODRjOS0wOTYzLTQ4ZjItODAxMC0wZTQ0ZjVkMThkYTUifQ==",
    "filename": "600.jpg",
    "extension": ".jpg",
    "mime_type": "image/jpeg",
    "size": 94361,
    "related_id": "941c84c9-0963-48f2-8010-0e44f5d18da5",
    "url": "http://api:5001/files/tools/941c84c9-0963-48f2-8010-0e44f5d18da5.jpg?timestamp=1787558393&nonce=3754a9f78bb6f3012ed2f5d7e67d4dff&sign=lH9d1n2AoQc8qagY_hDei7a_lsKzV1cvhVU1Suz560w="
    }
    ],
    "json": [
    {
    "data": []
    }
    ]
    }

    It runs perfectly within the orchestration page.

    However, during the new agent invocation, the file gets lost.

    Image

    The difference lies in the data processing section: one includes a file field, while the other does not.

    agent:{
    "model_mode": "chat",
    "prompts": [
    {
    "role": "system",
    "text": "你是一个图片识别器负责解析图片内容格式化输出描述文字",
    "files": []
    }
    ],
    "usage": {
    "prompt_tokens": 239,
    "prompt_unit_price": "0",
    "prompt_price_unit": "0",
    "prompt_price": "0",
    "completion_tokens": 199,
    "completion_unit_price": "0",
    "completion_price_unit": "0",
    "completion_price": "0",
    "total_tokens": 438,
    "total_price": "0",
    "currency": "USD",
    "latency": 9.457,
    "time_to_first_token": 6.186,
    "time_to_generate": 3.271
    },
    "finish_reason": "stop",
    "model_provider": "langgenius/openai_api_compatible/openai_api_compatible",
    "model_name": "jiaorong-kimi-k2.6"
    }

    The test run in the orchestration page looks like this:

    {
    "model_mode": "chat",
    "prompts": [
    {
    "files": [],
    "role": "system",
    "text": "你是一个图片识别器负责解析图片内容格式化输出描述文字"
    },
    {
    "files": [
    {
    "data": "data:image...[TRUNCATED]...WIAnif/9k=",
    "detail": "high",
    "type": "image"
    }
    ],
    "role": "user",
    "text": ""
    }
    ],
    "usage": {
    "completion_price": "0",
    "completion_price_unit": "0",
    "completion_tokens": 287,
    "completion_unit_price": "0",
    "currency": "USD",
    "latency": 10.351,
    "prompt_price": "0",
    "prompt_price_unit": "0",
    "prompt_tokens": 886,
    "prompt_unit_price": "0",
    "time_to_first_token": 2.416,
    "time_to_generate": 7.935,
    "total_price": "0",
    "total_tokens": 1173
    },
    "finish_reason": "stop",
    "model_provider": "langgenius/openai_api_compatible/openai_api_compatible",
    "model_name": "jiaorong-kimi-k2.6"
    }

  3. dosubot commented on Aug 24, 2026

    @dosubot

    Thank you for the detailed trace — this makes the bug very clear.

    Looking at the prompt payloads you shared, the key difference is the user message files field: the workflow orchestration test run includes the image as base64-encoded data (data:image/...), while the agent invocation shows "files": [] on every prompt message — the image is completely absent.

    This is a gap in how the new Agent App handles tool_file outputs. The _append_prompt_file_mappings function handles user-uploaded files (passed via prompt_file_mappings) by converting them to text locators appended to the query — but this only covers the initial user files, not files returned by a tool [1].

    When your image-download plugin returns a tool_file, the result goes through _handle_tool_result_event in app_runner.py, which records the result as a text observation only — there is no step that extracts the file, creates a MessageFile record, or injects it into the next LLM call's files array [2]. The workflow orchestration page uses a different code path (ToolFileMessageTransformer + QueueMessageFileEvent) that does handle this correctly [3].

    In short: the new Agent App path currently has no mechanism to take a tool_file returned by a plugin and inject it as a multimodal image into the next LLM invocation's prompt. The workflow test runner does this; the agent runner does not. This is the same underlying gap reported in #40425, which documents the problem in detail and has a proposed fix (PR #40455) that carries file references through the pydantic-ai event schema [3].

    As a possible workaround: instead of having the plugin output a tool_file, you could try having it return the image's original remote URL as a string in the text observation, and instruct the LLM to use that URL directly — though this is model-dependent and may not work for all providers.

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about dify with Dosu

  4. dosubot commented on Aug 24, 2026

    @dosubot

    Thanks for the detailed evidence — this makes the root cause very clear.

    Your traces confirm a specific gap in the new Agent App path: when a tool (your image-download plugin) returns a file with transfer_method: "tool_file", that file is successfully created and signed (the valid signed URL is visible in your tool output), but the agent's _convert_tool_response_to_text function discards the file entirely and replaces it with placeholder text when building the LLM prompt. The files: [] in your agent's prompt trace versus the files: [{data: "data:image..."}] in the workflow test-run trace is exactly this gap [1].

    The workflow orchestration test runner uses the legacy pipeline, which calls ToolFileMessageTransformer.transform_tool_invoke_messages() to download the tool file and inject it as base64 image data into the LLM prompt — which is why it works there. The new Agent App path has no equivalent mechanism: _handle_tool_result_event() stores only text observations, and no MessageFile records or image data ever reach the LLM prompt [1].

    This is tracked in #40425. A community contributor opened PR #40455 implementing a fix via the dify-agent SDK's ToolReturn.metadata channel — worth following for status updates [1].

    Workaround: Restructure your workflow so the vision model step is handled by a dedicated LLM node (not inside an agent invocation). The LLM node uses the legacy pipeline that correctly injects tool files into the prompt [1] [2]. Wire it so the image-download plugin runs first, passes its output file to the LLM node for vision processing, and then sends the text description to the agent for further reasoning.

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about dify

  5. lb20021008 commented on Aug 24, 2026

    @lb20021008
    Author

    @dosu The entire workflow is completely independent of the agent—the agent has no involvement whatsoever in the internal execution of the workflow.

    The issue is that the workflow shouldn't behave this way. It should be completely isolated from the agent—the agent should not have visibility into the workflow's internal execution, as this could inadvertently affect the workflow's behavior.

  6. lb20021008 commented on Aug 24, 2026

    @lb20021008
    Author
  7. dosubot commented on Aug 24, 2026

    @dosubot

    Your concern is valid, and the code confirms your expectation: the workflow is correctly isolated from the agent. When the workflow is invoked as a tool, WorkflowTool._invoke() runs it independently via WorkflowAppGenerator.generate() — the agent has zero visibility into the workflow's internal execution [1]. Only the workflow's declared output variables are returned to the agent. The agent never sees intermediate nodes, internal file transfers, or any internal state [2].

    The actual problem is at the output boundary, not inside the workflow. When the workflow outputs a file, WorkflowTool correctly calls self.create_file_message(file) for each file in the outputs [3]. That file message reaches the agent's tool result. However, in the new Agent App path, _convert_tool_response_to_text discards the file and replaces it with placeholder text like "image has been created and sent to user already…" — the image URL is lost before the LLM or frontend ever sees it. This is the bug documented in #40425 [4].

    So to summarize: the workflow's internal execution is not affected by the agent at all. The inconsistency you're seeing is in how the new Agent App path handles the output that the workflow returns — specifically, files are dropped at the conversion layer. There's an open PR (#40455) working on fixing this gap [4].

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about dify

  8. dosubot commented on Aug 24, 2026

    @dosubot

    I understand your point — and you're right that the workflow itself runs in full isolation. WorkflowTool._invoke() spins up an independent WorkflowAppGenerator.generate() call, so the agent has no involvement in the workflow's internal execution [1].

    The problem isn't that the agent interferes with the workflow — it's what happens after the workflow finishes. The workflow correctly produces the file, and _extract_files() picks it up and yields it as a ToolInvokeMessage [2]. But when that file message reaches the new Agent App's _convert_tool_response_to_text(), it gets silently discarded and replaced with placeholder text like "image has been created and sent to user already." The file never reaches the LLM prompt or the frontend [3].

    So the workflow is isolated as you'd expect — the agent doesn't affect its behavior. The gap is purely in the agent's tool response handling layer, which drops the file output after the workflow has already completed successfully.

    This matches #40425, which documents this exact failure mode in detail and has a proposed fix in PR #40455 [3]. You may want to cross-reference your report there, since your prompt traces showing "files": [] in the agent path versus working image data in the standalone workflow test provide a clean reproduction.

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about dify

  9. added
    🐞 bug
    and removed on Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions