openai's tool role dose not support name parameter #5216

Closed
opened 2026-02-21 18:09:54 -05:00 by yindo · 2 comments
Owner

Originally created by @sydnash on GitHub (Aug 26, 2024).

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

0.7.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. setting the model provider as openai api compatible and set the model's function call type as tool call.
  2. create an agent use this model and set a time tool which used to test the function call.
  3. ask the agent "what's the time?"
  4. if the openai api compatible server use the openai's tool definition (https://github.com/openai/openai-python/blob/main/src/openai/types/chat/chat_completion_message_tool_call_param.py), the request will faied.

✔️ Expected Behavior

complete a tool call logic

Actual Behavior

the request got an error like this:
too_error

Originally created by @sydnash on GitHub (Aug 26, 2024). ### 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 0.7.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. setting the model provider as openai api compatible and set the model's function call type as tool call. 2. create an agent use this model and set a time tool which used to test the function call. 3. ask the agent "what's the time?" 4. if the openai api compatible server use the openai's tool definition (`https://github.com/openai/openai-python/blob/main/src/openai/types/chat/chat_completion_message_tool_call_param.py`), the request will faied. ### ✔️ Expected Behavior complete a tool call logic ### ❌ Actual Behavior the request got an error like this: ![too_error](https://github.com/user-attachments/assets/27272243-3b00-4760-9219-398b0846585a)
yindo added the dependencies label 2026-02-21 18:09:54 -05:00
yindo closed this issue 2026-02-21 18:09:54 -05:00
Author
Owner

@sydnash commented on GitHub (Aug 26, 2024):

in the openai api's python client, the role of tool's parameter should not container a parameter as name.
chat_completion_message_tool_call_param.py

class ChatCompletionMessageToolCallParam(TypedDict, total=False):
    id: Required[str]
    """The ID of the tool call."""

    function: Required[Function]
    """The function that the model called."""

    type: Required[Literal["function"]]
    """The type of the tool. Currently, only `function` is supported."""

but in the openai api compatible implementation llm.py, the add a name to the message which cased the request verify failed.

it will be ok after change it to this code.

if message.name and message_dict.get("role", "") != "tool":
    message_dict["name"] = message.name
@sydnash commented on GitHub (Aug 26, 2024): in the openai api's python client, the role of tool's parameter should not container a parameter as name. [chat_completion_message_tool_call_param.py](https://github.com/openai/openai-python/blob/main/src/openai/types/chat/chat_completion_message_tool_call_param.py) ``` class ChatCompletionMessageToolCallParam(TypedDict, total=False): id: Required[str] """The ID of the tool call.""" function: Required[Function] """The function that the model called.""" type: Required[Literal["function"]] """The type of the tool. Currently, only `function` is supported.""" ``` but in the openai api compatible implementation [llm.py](https://github.com/langgenius/dify/blob/13be84e4d42d12000356c4143ac255bb4763b600/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py#L652), the add a name to the message which cased the request verify failed. it will be ok after change it to this code. ``` if message.name and message_dict.get("role", "") != "tool": message_dict["name"] = message.name ```
Author
Owner

@crazywoola commented on GitHub (Aug 26, 2024):

Please feel free to open a pr for this fix. :)

@crazywoola commented on GitHub (Aug 26, 2024): Please feel free to open a pr for this fix. :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5216