I’ve tested both gpt-4o and gpt-4o-mini, when giving the model WebSearchTool and structured outputs using output_type the JSON prematurely ends in EOF at around 6000 characters resulting in a validation error.
for TypeAdapter(GraphConstruction); 1 validation error for GraphConstruction
ValidationError: 1 validation error for GraphConstruction
Invalid JSON: EOF while parsing an object at line 1 column 6752 [type=json_invalid, input_value='{"entities":[{"entityId"...}],"links":[{"from_":1 ', input_type=str]
In fact almost the same issue happens in consumer facing ChatGPT when turning on search and instructing the model to find information and return in a JSON schema. Around the output length of 6000 characters in ChatGPT instead of EOF I consistently see the json interrupted by:
::contentReference[oaicite:0]{index=0}
Temprorary Solution: Limiting Max Tokens in ModelSettings to 128000 mysteriously gets rid of the JSON integrity problems and removes the validation error from JSON terminating mid generation. I consistently got a validation error without the Max Tokens and if I set Max Tokens to any arbitrary number error never occured again. Asking the model not to go beyond 5500 characers also works.
Hope this gets patched soon.