Safety Guardrail errors for tiny prompt (dropped into large app)

I was able to open a new project and play around with the Foundation Model, but when I dropped this class in a production app (with a lot of files) I'm running into Safety Guardrail errors for this very small prompt. Specifically it's "Safety guardrail was triggered after consecutive failures during streaming." Does it have something to do with the size of the app? I don't know what else to try to get it to work?

import FoundationModels import Playgrounds

@available(iOS 26.0, *)
#Playground {
    Task {
        do {
            let session = LanguageModelSession()
            let prompt = "Write a short story about a talking cat."
              let response = try await session.respond(to: prompt)
            print(response)
        } catch {
            print("Error: \(error)")
        }
    }
}
Answered by DTS Engineer in 845597022

For this I get this error: "Error: Resource (Local Sanitizer Asset) unavailable error." I can't figure out what might be the cause.

This seems to be the same error reported in this thread, and building with Xcode 26 beta 2 seems to help. Would you mind to give it a try and share your result here? Thanks.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

For an error related to guardrail, I'd suggest that you file a feedback report and share your report ID in this thread.

In your case, a prompt with more details may be able to avoid the error. You can give it a try.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Accepted Answer

For this I get this error: "Error: Resource (Local Sanitizer Asset) unavailable error." I can't figure out what might be the cause.

This seems to be the same error reported in this thread, and building with Xcode 26 beta 2 seems to help. Would you mind to give it a try and share your result here? Thanks.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Hello I have the same issue, when I try to run the app on Mac I don't have issues, while if I try to build on any iPhone simulator I get "sanitizer asset unavailable error 2" as in the screenshot

Safety Guardrail errors for tiny prompt (dropped into large app)
 
 
Q