Am I the only one experiencing this? Lately, in the Responses API (GPT-4.1-mini model), I saw that it’s generating invalid JSON. Does this happen to you?
{"section":"JOBS","function-name":"createIncidents","entity":"Alice","priority":"HIGH","description\":\"instalation\"} } Assistant can't process because there's an error in the JSON structure. I'll fix it. json fixed: {" :": " , " , " : " "}
Please place JSON for diagnosis in backticks for a code block (press the </> button on the forum’s editor).
Otherwise, what is seen here is a bunch of directional quotes that certainly would be invalid JSON, but that’s from the forum’s formatting.
I think you’re showing a single quote around the word priority.
That should not be possible if using a strict structured output.
It would be possible if the JSON is not constrained and you have not added a top_p parameter below 1.0 (such as 0.5), because then every generation is a gamble that you don’t get a bad token selected randomly.
Hello! Thanks for answering my questions . The problem is that this is with function calling. It’s a JSON schema with required fields and non-required fields. I don’t know if that’s the problem.
I had mistakenly thought the OP was giving an input → output example, and I thought “oh the input was wrong, that’s why the output was wrong”. But actually, they didn’t share an input example, both were output examples.
So really the question for the OP @celia.stelorder is, what was your input?
Hard to look deeper into the processing to figure out what might be possible to correct at the input level if we don’t have any information about the input itself.
Since the openai models are relatively black-box, we don’t know why it produced bad output, but can potentially help with reviewing input and considering if there’s any tweaks that could be provided to make better use of these models which sometimes produce bad output even under strict parameters…
Your failure is you are blaming the bad output on an unseen function specification, blaming the issue on the user. What is shown is the symptom. Not “tell me what is wrong with this symptom”.
It is impossible to pass a function specification that is a malformed JSON schema. You would get an API error.
The AI is the one producing a bad argument object.
Whoever marked this as a solution is daft.
The actual solution is to use a model that doesn’t stink, at near-deterministic sampling parameters, and find a way to construct a strict JSON schema with anyOf that can satisfy the need for optional keys to be produced.
Oh, your right. I went back and read the original post. I for some reason looked at it as input → output which it wasn’t, she was sharing two examples of malformed JSON output, not an input / output pair.
I’ll edit my response, and maybe someone can message Paul and get him to “unmark” my solution.