Skip to content

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

@JamalK

Description

@JamalK

Hello,

Thank you for making AnyLanguageModel! I'm really excited to migrate my project to use it.

In my project, I have a Generable struct with a version member (enum) that is non-generable. When I tried migrating to use AnyLanguageModel, I hit a silent failure that caused all the members of my generable struct to get values such as "placeholder"

System Version: macOS 26.3.1
Xcode Version: Version 26.2 (17C52)

Here's a minimal reproduction case that demonstrates it

import AnyLanguageModel


@Generable // this is only generable just for `SimpleOutput` conformance sake
enum OutputVersion: String {
    case v0
    case v1
}

@Generable
struct SimpleOutput {
    let version: OutputVersion

    @Guide(description: "The title of the document")
    let title: String

    @Guide(description: "List of topics", .minimumCount(2))
    let topics: [String]
}

@main
struct ALMRepo {
    static func main() async throws {
        let session = LanguageModelSession(model: SystemLanguageModel.default)
        let response = try await session.respond(
            to: "Classify this: Swift is a programming language by Apple.",
            generating: SimpleOutput.self
        )
        print(response.content)
    }
}

Output

SimpleOutput(version: ALMRepo.OutputVersion.v0, title: "placeholder", topics: ["placeholder", "placeholder"], _rawGeneratedContent: GeneratedContent(structure(properties: ["version": GeneratedContent(string("v0")), "topics": GeneratedContent(array([GeneratedContent(string("placeholder")), GeneratedContent(string("placeholder"))])), "title": GeneratedContent(string("placeholder"))], orderedKeys: ["version", "topics", "title"])))
Program ended with exit code: 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions