dify icon indicating copy to clipboard operation
dify copied to clipboard

Tool Response is empty in Agent node if response too long ( > 68000 )

Open EcoleKeine opened this issue 8 months ago • 9 comments

Self Checks

  • [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

1.3.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. create tool workflow long_text_creator return code node result:
def main() -> dict:
    return {
        "result": "1234567890" * 6800,
    }
  1. create chatflow, add agent, make agent use long_text_creator tool add long_text_creator tool node for compare

✔️ Expected Behavior

LLM agent call long_text_creator tool and get long text

❌ Actual Behavior

Agent node function call result:

{
  "output": {
    "tool_call_id": "long_text_creator",
    "tool_call_input": {},
    "tool_call_name": "long_text_creator",
    "tool_response": ""
  }
}

Tool Node result is ok

EcoleKeine avatar Apr 25 '25 01:04 EcoleKeine

The issue you're experiencing with the Agent node not handling long tool responses correctly might be related to the maximum payload size settings in Dify. The Agent node raises a ResponseSizeError if the response size exceeds the defined threshold, which could be causing the empty response you're seeing [1].

To address this, you can adjust the MAX_VARIABLE_SIZE setting in your docker/docker-compose.yaml file to handle larger responses. The default value is 204800, and increasing this value might help accommodate longer responses [2]. Additionally, check the HTTP_REQUEST_NODE_MAX_TEXT_SIZE setting, which defaults to 1MB, and increase it if necessary to ensure it can handle the size of your tool's response [3].

Make sure to restart your Docker containers after making these changes to apply the new configuration.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar Apr 25 '25 02:04 dosubot[bot]

Have you changed these?

https://github.com/langgenius/dify/blob/37e2f739091169eecc7c446d8232915bdaf6f895/docker/.env.example#L739-L752

crazywoola avatar Apr 25 '25 02:04 crazywoola

@crazywoola

those are changed: CODE_MAX_STRING_ARRAY_LENGTH=300 CODE_MAX_OBJECT_ARRAY_LENGTH=300 CODE_EXECUTION_READ_TIMEOUT=360

my .env:

# The sandbox service endpoint.
CODE_EXECUTION_ENDPOINT=http://sandbox:8194
CODE_EXECUTION_API_KEY=dify-sandbox
CODE_MAX_NUMBER=9223372036854775807
CODE_MIN_NUMBER=-9223372036854775808
CODE_MAX_DEPTH=5
CODE_MAX_PRECISION=20
CODE_MAX_STRING_LENGTH=80000
CODE_MAX_STRING_ARRAY_LENGTH=300
CODE_MAX_OBJECT_ARRAY_LENGTH=300
CODE_MAX_NUMBER_ARRAY_LENGTH=1000
CODE_EXECUTION_CONNECT_TIMEOUT=10
CODE_EXECUTION_READ_TIMEOUT=360
CODE_EXECUTION_WRITE_TIMEOUT=10
TEMPLATE_TRANSFORM_MAX_LENGTH=80000

EcoleKeine avatar Apr 25 '25 03:04 EcoleKeine

Image

I have tried, it seems working as expected.

crazywoola avatar Apr 25 '25 03:04 crazywoola

If the LLM still generates the results, then it means the connection with plugin_daemon is normal. Maybe it's a frontend limitation.

https://github.com/langgenius/dify/blob/44cdb3dceaf6414d3ca3e5fd864fed4ed1e335fa/web/service/base.ts

crazywoola avatar Apr 25 '25 04:04 crazywoola

@crazywoola

I have tried, it seems working as expected.

Only call by Agent Node will return empty Tool Node working as expected

EcoleKeine avatar Apr 25 '25 06:04 EcoleKeine

After my investigation, I found that the reason the tool results cannot be returned here is because the default size of the scanner in Go is 64k. When exceeding this size, it will skip the content. We can support larger response by increasing this limit, but we're still discussing exactly how large the adjustment should be.

Image

Nov1c444 avatar Apr 28 '25 01:04 Nov1c444

Now you can increase the byte transmission limit by configuring the two env parameters PLUGIN_STDIO_BUFFER_SIZE and PLUGIN_STDIO_MAX_BUFFER_SIZE in the dify-plugin-daemon service.

Image

Nov1c444 avatar May 13 '25 01:05 Nov1c444

Has anyone resolved this issue? I’d really appreciate some guidance.

homeant avatar May 21 '25 15:05 homeant

But when the input is long(~60k), the agent node returns an empty output after running for a few seconds. Is there a timeout setting causing this? With the same input, the LLM node can start generating output after waiting around 10 seconds.

Image

zhudongwork avatar Jul 02 '25 01:07 zhudongwork