On occasion my AI assistant function gets called with bad json arguments, its coming through like this, with the arguments embedded inside another object,
Example of bad arguments
"required_action":{
"type":"submit_tool_outputs",
"submit_tool_outputs":{
"tool_calls":[
{
"id":"call_3oXLTIRnUJ4eFKrqhWi0qYON",
"type":"function",
"function":{
"name":"get_answer",
"arguments":"{\n \"recipient_name\": \"functions.get_answer\",\n \"parameters\": {\n \"QuestionId\": 29537,\n \"Reasoning\": \"The summary says xxxxx.\",\n \"Answer\": [\"3 or less\"],\n \"Question\": \"xxxxxxxxxxxx?\"\n }\n}"
}
}
]
}
}
Normally it would come through like this
"required_action": {
"type": "submit_tool_outputs",
"submit_tool_outputs": {
"tool_calls": [
{
"id": "call_dGXJ3hlFeH5gc2mf0cti6nRh",
"type": "function",
"function": {
"name": "get_answer",
"arguments": "{\n \"QuestionId\": 29537,\n \"Reasoning\": \"xxxxxxxxxxxxx\",\n \"Answer\": [\"3 or less\"],\n \"Question\": \"xxxxxxxxx\"\n}"
}
}
]
}
}
My assistant function is like this
{
"name": "get_answer",
"description": "Look at the data summary, try and answer the question",
"parameters": {
"type": "object",
"properties": {
"QuestionId": {
"type": "integer",
"description": "The Question ID, the numeric ID only."
},
"Reasoning": {
"type": "string",
"description": "Tell me your reasoning as to why you have selected the answer your did"
},
"Answer": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of answers single or multiple as specified, applicable to the questionID being asked, any Date answers must be full dates in dd MMM yyyy if a date is only partial, then make it 1st of that month, if there is no month and only a year make the month January"
},
"Question": {
"type": "string",
"description": "The Question being asked escape any double quotes or anything that might break the JSON format"
}
},
"required": [
"QuestionId",
"Reasoning",
"Answer",
"Question"
]
}
}
I saw on another post you can return
{"status": "error", "message": "invalid parameters"}
So im doing that, just concerned that could end up in a forever loop, if it kept sending the wrong JSON in the arguments