Skip to content

Preserve named string enum dependencies in schema conversion#149

Merged
mattt merged 1 commit intomainfrom
mattt/fix-generable-without-guide
Mar 24, 2026
Merged

Preserve named string enum dependencies in schema conversion#149
mattt merged 1 commit intomainfrom
mattt/fix-generable-without-guide

Conversation

@mattt
Copy link
Collaborator

@mattt mattt commented Mar 24, 2026

Fixes #146

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a schema-conversion edge case where named string enums (typically coming from $defs / dependencies) were not preserved as named enum schemas during conversion to FoundationModels.DynamicGenerationSchema, causing reference resolution to fail and leading to silent placeholder outputs (Issue #146).

Changes:

  • Update JSONSchema → FoundationModels.DynamicGenerationSchema conversion to emit a named string-enum schema when a string schema with enum values is converted with a name.
  • Add a regression test ensuring a referenced, named string-enum dependency can be used to build a FoundationModels.GenerationSchema without throwing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Sources/AnyLanguageModel/Models/SystemLanguageModel.swift Preserves named string-enum dependencies by converting them into named anyOf: [String] schemas, enabling reference resolution.
Tests/AnyLanguageModelTests/DynamicSchemaConversionTests.swift Adds a regression test covering a named string enum dependency referenced from a root schema.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mattt mattt merged commit e85aa33 into main Mar 24, 2026
11 checks passed
@mattt mattt deleted the mattt/fix-generable-without-guide branch March 24, 2026 07:42
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.

Having @Generable enum used as a stored property without @Guide struct causes a silent failure (all members are a "placeholder" )

2 participants