Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

OpenAI strict mode rejects optional properties in nested objects

Open
#327 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
swift
Domain
api

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from huggingface/AnyLanguageModel

All issues in huggingface/AnyLanguageModel

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.