You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Map iOS 27 typed Foundation Models errors to stable codes #20
HybridLanguageModelSession.mapGenerationError only matches GenerationError. On iOS 27 a guardrail violation or context overflow may fall through to the generic SESSION_RESPONSE_ERROR / SESSION_STREAMING_ERROR, and the context-overflow recovery path (catch GenerationError.exceededContextWindowSize) may never run.
Proposal
Map each iOS 27 error type to the existing stable codes (CONTEXT_EXCEEDED, GUARDRAIL_VIOLATION, REFUSAL, RATE_LIMITED, SESSION_BUSY, ASSETS_UNAVAILABLE, DECODING_FAILURE, UNSUPPORTED_LANGUAGE_OR_LOCALE, UNSUPPORTED_GUIDE) so JS callers see the same codes on iOS 26 and 27.
Add codes for the new cases: UNSUPPORTED_CAPABILITY, UNSUPPORTED_TRANSCRIPT_CONTENT, TIMEOUT.
Run context-overflow recovery for LanguageModelError.contextSizeExceeded too.
Confirmed on a real device model (macOS 27, AFM 3 Core, Xcode 27 SDK). This is not a "may": the iOS 26 catch blocks never fire on OS 27.
Trigger
Thrown type on OS 27
is GenerationError
respond with a 20k-token prompt
LanguageModelError.contextSizeExceeded
false
streamResponse with the same prompt
LanguageModelError
false
Second respond while the first is in flight
GeneratedContent.ParsingError ("Session ended without producing a response")
false
Tool call throws
LanguageModelSession.ToolCallError (unchanged)
n/a
The result was the same with a deployment target of 26.0 and of 27.0, so the runtime picks the new types no matter what the app links against. On iOS 27 today, context overflow returns SESSION_RESPONSE_ERROR, recovery never runs, and wasContextReset stays false.
Activity
corasan commentedon Oct 16, 2026
Confirmed on a real device model (macOS 27, AFM 3 Core, Xcode 27 SDK). This is not a "may": the iOS 26 catch blocks never fire on OS 27.
is GenerationErrorrespondwith a 20k-token promptLanguageModelError.contextSizeExceededfalsestreamResponsewith the same promptLanguageModelErrorfalserespondwhile the first is in flightGeneratedContent.ParsingError("Session ended without producing a response")falsecallthrowsLanguageModelSession.ToolCallError(unchanged)The result was the same with a deployment target of 26.0 and of 27.0, so the runtime picks the new types no matter what the app links against. On iOS 27 today, context overflow returns
SESSION_RESPONSE_ERROR, recovery never runs, andwasContextResetstaysfalse.fix(ios): map iOS 27 typed errors to stable codes