Malformed function-calling arguments

I’m running into a case where the arguments for a single named function are almost always malformed within the API response for function_call.

Example response:

{"name"=>"final_answer", "arguments"=>"\nObservation: The size of your Rails EC2 instance is 't2.large'."}

arguments should be an object with an answer key. Here’s the relevant part of my schema sent in the API request:

      "name": "final_answer",
      "description": "Provide me with a final answer to my question.",
      "parameters": {
        "type": "object",
        "properties": {
          "answer": {
            "type": "string",
            "description": "The text you'd like to show to me as your final answer."
        "required": ["answer"]

If I append a message like this, the response seems to self-correct:

      "role": "assistant",
      "content": "The last function arguments you returned were malformed."

Anyone else seen this? Again, odd this only happens (so far) with a single function for me.

1 Like