Missing parameter 'tool_call_id': messages with role 'tool' must have a 'tool_call_id'."

MJ Waanders 0 Reputation points
2024-06-24T20:09:31.8166667+00:00

Hi all,

Please consider the following messages array that I send to Azure OpenAI (using GPT4o). This produces the error: "Missing parameter 'tool_call_id': messages with role 'tool' must have a 'tool_call_id'.", But, as you can see, the property is there. Any idea what I might be doing wrong?

 "messages": [
    {
      "role": "system",
      "content": "You are an assistant... <shortened>"
    },
    {
      "role": "assistant",
      "content": "Hey there! Thanks for calling C Clinics. Want to book an appointment?"
    },
    {
      "role": "user",
      "content": "<shortened>"
    },
    {
      "role": "assistant",
      "content": "<shortened>"
    },
    {
      "role": "assistant",
      "tool_calls": [
        {
          "function": {
            "arguments": "{\"date\":\"2024-7-04T14:00:00\",\"treatment",
            "name": "check_appointment_availability"
          },
          "id": "call_UppFZO2cl44QV4EDaJSBX1bJ",
          "type": "function"
        }
      ]
    },
    {
      "role": "tool",
      "name": "check_appointment_availability",
      "content": "Yes, we have slots available",
      "tool_call_id": "call_UppFZO2cl44QV4EDaJSBX1bJ"
    }
  ]
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,192 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ganeshkumar R 660 Reputation points
    2024-06-24T20:45:50.13+00:00

    The error you are encountering, "Missing parameter 'tool_call_id': messages with role 'tool' must have a 'tool_call_id'," suggests that there is an issue with how the tool_call_id parameter is being interpreted or formatted in your JSON.

    Let's review and correct your JSON structure:

    Corrected JSON Structure

    
    {
    
      "messages": [
    
        {
    
          "role": "system",
    
          "content": "You are an assistant... <shortened>"
    
        },
    
        {
    
          "role": "assistant",
    
          "content": "Hey there! Thanks for calling C Clinics. Want to book an appointment?"
    
        },
    
        {
    
          "role": "user",
    
          "content": "<shortened>"
    
        },
    
        {
    
          "role": "assistant",
    
          "content": "<shortened>"
    
        },
    
        {
    
          "role": "assistant",
    
          "tool_calls": [
    
            {
    
              "function": {
    
                "arguments": "{\"date\":\"2024-7-04T14:00:00\",\"treatment",
    
                "name": "check_appointment_availability"
    
              },
    
              "id": "call_UppFZO2cl44QV4EDaJSBX1bJ",
    
              "type": "function"
    
            }
    
          ]
    
        },
    
        {
    
          "role": "tool",
    
          "name": "check_appointment_availability",
    
          "content": "Yes, we have slots available",
    
          "tool_call_id": "call_UppFZO2cl44QV4EDaJSBX1bJ"
    
        }
    
      ]
    
    }
    
    

    By ensuring that the structure and placement of the tool_calls and tool_call_id are correct, you should be able to resolve the error and successfully validate the messages.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.