OpenAI strict mode rejects optional properties in nested objects
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
Research direction
Start from toJSONValueForOpenAIStrictMode() and toJSONValueForOpenResponsesStrictMode(), which currently apply strict-mode rules only to the root object. Walk the schema recursively so every nested object gets the same treatment: all properties listed in required, and optional property types made nullable. The issue's Contact/Address example and the enum-case note in #322 are the cases to check. Done when nested optional properties pass strict mode in both OpenAI and Open Responses schemas, with tests covering nested and enum cases.
Written by the indexing model from the issue text.
Description
OpenAILanguageModel and OpenResponsesLanguageModel send structured output schemas with strict: true. OpenAI's strict mode requires every property of every object to be in required, with a null type for an optional one. toJSONValueForOpenAIStrictMode() and toJSONValueForOpenResponsesStrictMode() only do this for the root object, so an optional property in a nested object is left out of required.
For example, unit isn't in Address's required here:
@Generable
struct Contact {
var name: String
var address: Address
}
@Generable
struct Address {
var street: String
var unit: String?
}
The same goes for enum cases with optional values, like case note(String?) (#322).
The fix is probably to apply the root's rules to every object in the schema, and make each optional property's type nullable.
- Dominant language
- Swift
- Stars
- 948
- Forks
- 99
- Avg merge
- 19h 50m
- Merged PRs (30d)
- 51
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from huggingface/AnyLanguageModel
-
OpenAILanguageModel replays tool-call arguments as GeneratedContent's Codable form, not JSONPossibly taken @gtokman claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
huggingface/AnyLanguageModel#324 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 18/100
huggingface/AnyLanguageModel#328 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 50/100
huggingface/AnyLanguageModel#326 · 2 comments ·
Maintainers usually reply within 1 day
-
Support the Gemini Interactions API in GeminiLanguageModelMay be free again @rizwankce claimed this 8 days ago, and no pull request is open. Open
Difficulty 5/5 Over a week Newbie friendliness 45/100
huggingface/AnyLanguageModel#302 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
huggingface/AnyLanguageModel#291 · 1 reaction ·
Maintainers usually reply within 1 day
All issues in huggingface/AnyLanguageModel
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
[BUG] File transcription skips audio chunks shorter than one secondPossibly taken @sabbah13 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
altic-dev/FluidVoice#1161 ·
Maintainers usually reply within 1 day
-
swift.md: `Date(myString, strategy: .iso8601)` example omits `try` — the initializer is throwingOpen
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
githubnext/desktop-tools#25 ·
Maintainers usually reply within 1 day
-
bug core p3
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
RunanywhereAI/runanywhere-sdks#1083 ·
Maintainers usually reply within 5 days