Description
The iOS SDK (MediaPipeTasksGenAI CocoaPods) does not expose a cancel/stop generation API for LlmInference, while Android and Web already support it.
Current State
| Platform |
Cancel API |
Status |
| Android |
cancelGenerateResponseAsync() |
✅ Available |
| Web |
cancelProcessing() |
✅ Available since @mediapipe/tasks-genai@0.10.26 (#6128) |
| iOS |
— |
❌ Missing |
Use Case
Users want to cancel an ongoing LLM response mid-stream — this is a standard UX pattern in all chat AI applications. Without cancellation on iOS, the only workaround is closing the entire session and creating a new one, which is slow and wastes resources.
Requested API
Add a cancelProcessing() or equivalent method to LlmInference on iOS (Swift), matching the Android and Web APIs.
Swift example:
let llmInference = try LlmInference(options: options)
// Start async generation
llmInference.generateResponseAsync(inputText: prompt) { partial, error in ... }
// Cancel mid-stream
llmInference.cancelProcessing() // <-- this doesn't exist on iOS
Context
We maintain flutter_gemma, a Flutter plugin for on-device LLM inference. Cancel generation is one of the most requested features by our users (see DenisovAV/flutter_gemma#34, DenisovAV/flutter_gemma#194).
Related
Description
The iOS SDK (
MediaPipeTasksGenAICocoaPods) does not expose a cancel/stop generation API forLlmInference, while Android and Web already support it.Current State
cancelGenerateResponseAsync()cancelProcessing()@mediapipe/tasks-genai@0.10.26(#6128)Use Case
Users want to cancel an ongoing LLM response mid-stream — this is a standard UX pattern in all chat AI applications. Without cancellation on iOS, the only workaround is closing the entire session and creating a new one, which is slow and wastes resources.
Requested API
Add a
cancelProcessing()or equivalent method toLlmInferenceon iOS (Swift), matching the Android and Web APIs.Swift example:
Context
We maintain flutter_gemma, a Flutter plugin for on-device LLM inference. Cancel generation is one of the most requested features by our users (see DenisovAV/flutter_gemma#34, DenisovAV/flutter_gemma#194).
Related
cancelProcessing()(fixed in 0.10.26)