azure openai o3-mini expecting stream response but sete stream false in request. #72

Closed
opened 2026-02-16 10:17:59 -05:00 by yindo · 2 comments
Owner

Originally created by @ufo009e on GitHub (Mar 12, 2025).

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.0.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I installed azure openai plugin 0.0.8, when using o3-mini modle, stream always set to false in http request, but the plugin is expecting stream response.

Image
2025-03-12 14:57:47.584 ERROR [Thread-411 (_generate_worker)] [app_generator.py:257] - Unknown Error when generating
Traceback (most recent call last):
  File "/app/api/core/app/apps/agent_chat/app_generator.py", line 237, in _generate_worker
    runner.run(
  File "/app/api/core/app/apps/agent_chat/app_runner.py", line 245, in run
    self._handle_invoke_result(
  File "/app/api/core/app/apps/base_app_runner.py", line 271, in _handle_invoke_result
    self._handle_invoke_result_stream(invoke_result=invoke_result, queue_manager=queue_manager, agent=agent)
  File "/app/api/core/app/apps/base_app_runner.py", line 312, in _handle_invoke_result_stream
    text += result.delta.message.content
TypeError: can only concatenate str (not "list") to str

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @ufo009e on GitHub (Mar 12, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.0.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce I installed azure openai plugin 0.0.8, when using o3-mini modle, stream always set to false in http request, but the plugin is expecting stream response. <img width="493" alt="Image" src="https://github.com/user-attachments/assets/36165e3d-c125-4314-98d1-0f107597af8a" /> ``` 2025-03-12 14:57:47.584 ERROR [Thread-411 (_generate_worker)] [app_generator.py:257] - Unknown Error when generating Traceback (most recent call last): File "/app/api/core/app/apps/agent_chat/app_generator.py", line 237, in _generate_worker runner.run( File "/app/api/core/app/apps/agent_chat/app_runner.py", line 245, in run self._handle_invoke_result( File "/app/api/core/app/apps/base_app_runner.py", line 271, in _handle_invoke_result self._handle_invoke_result_stream(invoke_result=invoke_result, queue_manager=queue_manager, agent=agent) File "/app/api/core/app/apps/base_app_runner.py", line 312, in _handle_invoke_result_stream text += result.delta.message.content TypeError: can only concatenate str (not "list") to str ``` ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the good first issue label 2026-02-16 10:17:59 -05:00
yindo closed this issue 2026-02-16 10:17:59 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 12, 2025):

I found a similar discussion thread titled "azure openai api Stream options setting" which is currently unsolved [1].

Regarding your issue, the TypeError in the _handle_invoke_result_stream method suggests that result.delta.message.content is a list, but the code is attempting to concatenate it as if it were a string. To resolve this, ensure that result.delta.message.content is indeed a string before concatenating it. You might need to convert or join the list elements into a string format.

Additionally, the stream parameter in the HTTP request is set based on the response_mode. If response_mode is "streaming", stream should be set to True; otherwise, it is set to False <sup>[[2]](https://github.com/langgenius/dify/blob/main/sdks/python-client/dify_client/client.py)</sup><sup>[[3]](https://github.com/langgenius/dify/blob/main/sdks/nodejs-client/index.js)</sup>. Ensure that the response_mode is correctly set to "streaming" if a stream response is expected.

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] commented on GitHub (Mar 12, 2025): <!-- Answer --> I found a similar discussion thread titled "azure openai api Stream options setting" which is currently unsolved <sup>[[1]](https://github.com/langgenius/dify/discussions/9715)</sup>. Regarding your issue, the `TypeError` in the `_handle_invoke_result_stream` method suggests that `result.delta.message.content` is a list, but the code is attempting to concatenate it as if it were a string. To resolve this, ensure that `result.delta.message.content` is indeed a string before concatenating it. You might need to convert or join the list elements into a string format. Additionally, the `stream` parameter in the HTTP request is set based on the `response_mode`. If `response_mode` is "streaming", `stream` should be set to `True`; otherwise, it is set to `False <sup>[[2]](https://github.com/langgenius/dify/blob/main/sdks/python-client/dify_client/client.py)</sup><sup>[[3]](https://github.com/langgenius/dify/blob/main/sdks/nodejs-client/index.js)</sup>`. Ensure that the `response_mode` is correctly set to "streaming" if a stream response is expected. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/316963a5-a2b2-4c78-a87d-9658b70591e4?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/316963a5-a2b2-4c78-a87d-9658b70591e4?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/316963a5-a2b2-4c78-a87d-9658b70591e4?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/316963a5-a2b2-4c78-a87d-9658b70591e4?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/316963a5-a2b2-4c78-a87d-9658b70591e4?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/316963a5-a2b2-4c78-a87d-9658b70591e4?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/316963a5-a2b2-4c78-a87d-9658b70591e4?feedback_type=other)</sup>
Author
Owner

@kurokobo commented on GitHub (Mar 13, 2025):

This can be splitted into two issues:

  • The o3-mini is always invoked with stream: false
  • When the LLM on AOAI requests tool calls with stream: false, the message content is [] instead of "", which causes a TypeError: can only concatenate str (not "list") to str.
@kurokobo commented on GitHub (Mar 13, 2025): This can be splitted into two issues: - [x] The o3-mini is always invoked with `stream: false` - [x] When the LLM on AOAI requests tool calls with `stream: false`, the message content is `[]` instead of `""`, which causes a `TypeError: can only concatenate str (not "list") to str`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#72