high severityOpenAI Chat Completions API (tool_calls parsing in client code)

JSONDecodeError when parsing tool_call.function.arguments, e.g. "Expecting property name enclosed in double quotes: line 1 column 112 (char 111)" with args like "{'query': 'ha', 'num': 5}".

Root cause

OpenAI models occasionally generate tool call arguments using Python dict syntax with single quotes (e.g. {'key': 'value'}) instead of strict JSON with double quotes ({\"key\": \"value\"}), causing json.loads to fail with JSONDecodeError when client code parses message.tool_calls[0].function.arguments.

openai-pythonJSONDecodeErrortool_callsfunction_callingsingle_quotes

Citations