Skip to content

fix(prompt): update OpenAI JSON schema generation for serialization o…#1943

Open
grantlerduck wants to merge 1 commit intoJetBrains:developfrom
grantlerduck:fix/openai-serialization
Open

fix(prompt): update OpenAI JSON schema generation for serialization o…#1943
grantlerduck wants to merge 1 commit intoJetBrains:developfrom
grantlerduck:fix/openai-serialization

Conversation

@grantlerduck
Copy link
Copy Markdown
Contributor

Summary

  • Nullable List<X>? fields produced {"type": ["array", "null"], "items": {...}}, which OpenAI's
    GPT-5-family strict-mode validator rejects (surfaces as 'Invalid schema for response_format ... got "type": "None"'). Switch OpenAIStandardJsonSchemaGenerator.processList to emit
    {"anyOf": [{"type": "array", "items": ...}, {"type": "null"}]} for nullable lists, mirroring
    the shape already used for nullable objects.
  • Non-nullable lists, nullable primitives, and the LLM-agnostic StandardJsonSchemaGenerator are
    unchanged. Only the OpenAI-specific generator is touched, so other providers keep their existing
    type-union encoding.
  • Adds a regression test (testGenerateOpenAIStandardJsonSchemaForNullableLists) covering both
    primitive (List<String>?) and $ref (List<Tag>?) item types.

Out of scope (could follow up)

  • OpenAIBasicJsonSchemaGenerator still emits the OpenAPI-3.0-style nullable: true keyword, which
    OpenAI strict mode silently ignores. Same root cause family, different generator — happy to file
    a follow-up if useful.

closes #1930

@grantlerduck grantlerduck force-pushed the fix/openai-serialization branch from fcd5fc5 to ba54077 Compare May 3, 2026 08:11
@serge-p7v serge-p7v requested a review from EugeneTheDev May 8, 2026 14:32
@grantlerduck grantlerduck force-pushed the fix/openai-serialization branch from ba54077 to 7ee683e Compare May 9, 2026 07:43
@grantlerduck
Copy link
Copy Markdown
Contributor Author

Just rebased. There was an agent run test which ran into a deadlock unrelated to my changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: OpenAI gpt-5+ model family JSON schema issues

1 participant