GPT-4-turbo and GPT-4o changing the name in function calling

When using the function-calling API with GPT-4-turbo and GPT-4o models, redundant characters are removed from the function name in the response. In our current implementation, we use an ID as the function name, making it unusable. This works with GPT-3.5 and GPT-4 models, but there is an issue with GPT-4-turbo and GPT-4o models.

Request body:

{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": "Get me details of a blog authored by Dennis Ritchie, with title \"Why linux is the best OS\", which is published and is of version 1"
    }
  ],
  "max_tokens": 500,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "60f092293f56478bb2cf1dbdb7e907cc",
        "description": "This is a function which returns details about an blog with given details.\n\"author\": The authors name of the blog (type string, Eg: \"Daniel Ritchie\")\n\"title: The title of the blog (type string, Eg: \"Why windows 10 is better than windows 11\")\n\"published\": If the blog is published or not (type boolean, Eg: false)\n\"version\": Version of the blog (type number, Eg: 1)",
        "parameters": {
          "type": "object",
          "properties": {
            "author": {
              "type": "string"
            },
            "published": {
              "type": "boolean"
            },
            "title": {
              "type": "string"
            },
            "version": {
              "type": "number"
            }
          },
          "required": [
            "author",
            "published",
            "title"
          ]
        }
      }
    }
  ]
}

Response Body:

[
  {
    "index": 0,
    "message": {
      "role": "assistant",
      "tool_calls": [
        {
          "id": "call_2oSMOmki5buqE77H0p8ua1Fn",
          "type": "function",
          "function": {
            "name": "60f092293f56478bb2cf1db7e907cc",
            "arguments": "{\"author\":\"Dennis Ritchie\",\"published\":true,\"title\":\"Why linux is the best OS\",\"version\":1}"
          }
        }
      ]
    },
    "logprobs": null,
    "finish_reason": "tool_calls"
  }
]

In the request body, the function name is 60f092293f56478bb2cf1dbdb7e907cc, but in the response, it changes to 60f092293f56478bb2cf1db7e907cc, with dbdb being shortened to db.

Is there a way to fix this issue?

The function name output is not from code. The Ai is the one that is writing the function name from the specification it receives.

You are making it much harder on the AI model than were it to receive a meaningful name that reflected the purpose of the function.

Hey, thank you for the reply, I also tried with passing names likes, get_blog_details-ID-60f092293f56478bb2cf1dbdb7e907cc , still it would remove the duplicate set of characters, and my main area of concern is, it worked fine with the older models but finding issue with newer models.

OpenAI keeps swapping models around, and they don’t seem to be getting stronger.

It might be well advised to frame the problem that the LLM is supposed to solve as simple as possible for maximum stability.

Since you can programmatically rewrite your functions anyways, why do you need the model to copy this random string?

We are integrating it with our product where the ID is required, and it must be the function’s name.