When the @Generable is applied toward a Swift struct declared within another struct, and when said nested struct is defined as the type of one of the properties of another @Generable type, which is in turn defined as the output format of Foundation Model session, Foundation Model can stuck in a loop trying to create a infinitely nested response, until the context window limit exceeded error is triggered.
I have filed feedback FB19987191 with a demo project. Is this expected behavior?
Thank you so much for the detailed feedback. That really helps!
We're working on investigating the underlying issue, but the problem in your code is that you have 3 different @Generable types named GenerableData
:
TransactionItem.GenerableData
Account.GenerableData
Category.GenerableData
At runtime all 3 types are getting mistaken for TransactionItem.GenerableData
, hence the infinite generation loop. To fix, rename your other GenerableData
types to have a unique name, like AccountGenerableData
and CategoryGenerableData
.
We're investigating this type confusion issue, so please kindly use this unique-type-name workaround for now.