"FoundationModels GenerationError error 2" on iOS 26 beta 3

Hi all, I'm working on an app that utilizes the FoundationModels found in iOS 26. I updated my phone to iOS 26 beta 3 and am now receiving the following error when trying to run code that worked in beta 2:

Al Error: The operation couldn't be completed. (FoundationModels.LanguageModelSession.Genera- tionError error 2.)

I admit I'm a bit of a new developer, but any idea if this is an issue with beta 3 or work that I'll need to do to adapt my code to some changes in the AI API?

Thank you!

Answered by DTS Engineer in 847952022

Thanks for providing more info. Error code 2 indicates a guardrail violation, meaning that the system determined your prompt might contain "sensitive or unsafe content," and triggered the safety guardrails.

To avoid the violation, consider rephrasing your prompt by removing words that are potentially sensitive or unsafe, if any. If your prompt is short, adding more details may help as well. For more information about prompt safety, watch the WWDC25 video: Explore prompt design & safety for on-device foundation models.

If your input doesn't really contain any sensitive or unsafe content, I’d suggest that you follow this post to file an actionable feedback report using LanguageModelFeedbackAttachment, and then share your report ID here. Thanks.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Would you mind to share how you trigger the issue (with what API), and what error message you get? Thanks.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Hello,

Thank you for looking into this. Here are the details you requested:

API Triggering the Issue: The error occurs when calling LanguageModelSession.streamResponse(to:) in the FoundationModels framework. This happens consistently in our app since updating to iOS 26 Developer Beta 3.

The specific error we receive is FoundationModels.LanguageModelSession.GenerationError error 2.

This was working as expected on Beta 2. Please let me know if you need any other information!

I'm also seeing this using Xcode 26 beta 2 and an iPhone 16 Pro Max on iOS 26 beta 3.

In a demo chat app project, the error is thrown for roughly half of prompts. Often trying the same prompt multiple times will succeed or fail at random.

It reliably happens when using the FoundationModelsTripPlanner sample code. Every attempt to generate an itinerary throws an error:

The operation couldn’t be completed. (FoundationModels.LanguageModelSession.GenerationError error 2.)

Printing description of error:
▿ GenerationError
  ▿ guardrailViolation : Context
    - debugDescription : "May contain sensitive or unsafe content"
    ▿ underlyingErrors : 1 element
      ▿ 0 : GenerationError
        ▿ guardrailViolation : Context
          - debugDescription : "May contain unsafe content"
          - underlyingErrors : 0 elements

Thanks for providing more info. Error code 2 indicates a guardrail violation, meaning that the system determined your prompt might contain "sensitive or unsafe content," and triggered the safety guardrails.

To avoid the violation, consider rephrasing your prompt by removing words that are potentially sensitive or unsafe, if any. If your prompt is short, adding more details may help as well. For more information about prompt safety, watch the WWDC25 video: Explore prompt design & safety for on-device foundation models.

If your input doesn't really contain any sensitive or unsafe content, I’d suggest that you follow this post to file an actionable feedback report using LanguageModelFeedbackAttachment, and then share your report ID here. Thanks.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

"The Apple TV+ sci-fi series Murderbot tests that cultural assumption with a quirky conceit: It imagines a future in which an artificial-intelligence program wouldn’t want anything to do with humans at all." -> got FoundationModels.LanguageModelSession.GenerationError.guardrailViolation(FoundationModels.LanguageModelSession.GenerationError.Context(debugDescription: "May contain unsafe content".

90% of normal content is blocked by FoundationModels on iOS 26 beta 3, it looks very poor. Why is Apple trying to extremely protect something from content?

Thank you, Ziqiao. I am pretty certain that my content should not bump up against any reasonable guardrails and as I said before, none were being triggered in beta 1 and beta 2.

I have reviewed the prompts and they contain only standard HealthKit data and benign instructions.

I am attempting to file a report and running into some difficulties but will keep trying.

Since installing beta 3, literally every single request I send to Foundation Models generates a guardrails error where before it was about 10%.

Since we don't have Xcode yet, I haven't re-tested my evals but it seems like something really big changed in this seed. I would call it a big regression to the point of no longer being unusable.

It is ridiculously restrictive. As it is, it's unusable in any real-world scenario.

What here is dangerous?

instructions: """ Read the user's input and tag it with the most relevant manifestation method from the list below.

                   Use intent, topic, tone, or keywords in the input to choose the best match.

                   Return only the method name listed in the right-hand column.

                   Tag Mapping:
                   “369 Manifestation” → manifest369method

                  

                   User Input:
                """

I am also running into the exact same issue. It was working on beta 26.2 and now suddenly it is not working on beta 26.3. Error 2 as well. The only sensitive information that is being handled is health information. I would think that should be allowed.

Just tried the sample code again with Xcode 26 beta 3, the same problem persists. All itinerary generations are failing with the same guardrail error. Some of the hashtag generations succeed, but one weird thing I saw was the "White Cliffs of Dover" landmark generating one extremely long hashtag that stretched the window off the side of the screen. The LLM got stuck in a loop generating the same phrase repeatedly.

Yeah. Guardrails are part of the system but the change in this beta is so severe, they trigger almost all the time.

I suggest we all file Feedbacks and quickly. We're already mid-July... I'll post my FB number once I have it all written up.

Filed FB18712543

Thank you for filing Feedback!

I filed a second one with my own content, FB18787534.

Just to share a public example, this is an example of text the model won't summarize saying it's "unsafe". Seems pretty anodyne to me... let alone trying to summarize news about current events, obits, etc.

Here’s a product recommendation long in the making. Four years ago this month, Matthew Panzarino was my guest on The Talk Show and at one point he recommended Moft’s Snap-On iPhone Stand/Wallet. It uses a very clever origami-style folding design. Folded flat it kind of just looks like a leather MagSafe wallet. But folded open it works as a stand — and as a stand, it works both horizontally and vertically. Borrowing images from Moft’s website:You can also use it with the stand oriented vertically but the phone horizontally.I bought one of these right after that episode of the show, and I’ve been using it ever since. And every so often when I use it, I think to myself that I should write a post recommending it. I’ve waited so long that Panzarino has been back on The Talk Show five times since the episode in which he recommended it, but here we are. The thing is, I use it both in my kitchen and while travelling, and so I’ll often find myself in the kitchen, rooting around the drawer in which I keep it stashed, only to realize it’s downstairs in my office in my laptop bag. Or, worse, I’ll find myself looking for it in my laptop bag while I’m sitting on an airplane 35,000 feet in the air, only to realize it’s back home in my kitchen. So I ordered a second one today — which I should have done like 3.5 years ago.I own a few similar/competing products, like these PopSocket-y rings from Anker and Belkin. I have no idea why I own both of those rings when I don’t like either of them as much as the Moft foldable stand. The problem with these rings is that they’re only able to prop the phone horizontally. Watching video is almost certainly the most common use case for these stands, but I do often use my iPhone propped up vertically, like for FaceTime calls and when I’m writing on it using a Bluetooth keyboard. I’m going to give both of these rings away — there’s nothing they do better than the Moft stand. The Moft stand even works better as a hand-holding grip.I’ve never used the Moft stand as a wallet, but if you want to, it holds two cards. Prime “Day” lasts a week and it’s still running until midnight Pacific tonight, but the Moft stand doesn’t have a Prime Day discount: it’s the same price at Amazon as it is from Moft’s website: $30. Well worth it. I love this thing. (Buy yours wherever you want, of course, but the Amazon link a few sentences back will throw some filthy affiliate lucre my way.)

guardrailViolation(FoundationModels.LanguageModelSession.GenerationError.Context(debugDescription: "May contain sensitive or unsafe content", underlyingErrors: [FoundationModels.LanguageModelSession.GenerationError.guardrailViolation(FoundationModels.LanguageModelSession.GenerationError.Context(debugDescription: "May contain unsafe content", underlyingErrors: []))]))

I ran across similar issues. In my case I'm hitting the Guardrail Violation for prompts over (roughly) 4000 characters. Under that, I'm fine. Innocuous prompt. Also filed FB18809149. I wondered if it might be a false exceedsContextWindowSize error, but with comments above, maybe not.

"FoundationModels GenerationError error 2" on iOS 26 beta 3
 
 
Q