Error: Peer Closed Connection Without Sending Complete Message Body in Claude 3.5 (Sonnet 20240620)
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
0.9.1
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
I encountered two issues while using the Dify platform with an agent powered by Claude 3.5 (Sonnet 20240620).
To reproduce this issue, I created an agent using Claude 3.5 (Sonnet 20240620) on the Dify platform. I initiated a conversation with the agent by sending a text message and continued exchanging messages. The conversation proceeded normally for the first 14 messages. In normal operation, the message field contains structured content, such as:
message: [{role: "user",...}, {role: "assistant",...}, {role: "user",...}, {role: "assistant",...}, {role: "user",...},...]
However, on the 14th message, the system stopped responding, and the following error was returned with an empty message field:
[anthropic] Error: peer closed connection without sending complete message body (incomplete chunked read) message: "" status: "error"
Attempting to continue the conversation by sending another message resulted in a second error instead of recovery:
[anthropic] Bad Request Error, Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages.29: all messages must have non-empty content except for the optional final assistant message'}}
✔️ Expected Behavior
The agent should respond consistently without interruptions or errors.
❌ Actual Behavior
error occurred:
[anthropic] Error: peer closed connection without sending complete message body (incomplete chunked read)
[anthropic] Bad Request Error, Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages.29: all messages must have non-empty content except for the optional final assistant message'}}
I found a similar open issue titled "[azure_openai] Error: peer closed connection without sending complete message body (incomplete chunked read)" which might be related to the problem you're experiencing [1]. However, there is no solution found in the comments of that issue.
Additionally, there is a related discussion titled "Bug of Use Claude" that might provide some insights, but it remains unsolved [2].
Regarding the "peer closed connection" error, there isn't specific information available in the repository about the known causes or how the Dify platform handles message chunking that could lead to an incomplete chunked read. Similarly, for the "invalid_request_error," there are no specific requirements for message content documented in the repository.
For the Bad Request Error with code 400, the Dify platform has several error handling mechanisms in place, such as CompletionRequestError and ProviderNotInitializeError, which provide specific feedback and guidance on resolving issues [3][4][5]. However, these do not directly address the "invalid_request_error" you encountered.
You might want to check if there are any updates or patches available for the Dify platform that address these issues, or consider reaching out to the maintainers for further assistance.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other
I have the same problem, how can I solve it. TOT