Fix #ImplicitStrongCapture warning in generateAppleOnDeviceToolResponse
Rune caught this via a Release build (build.sh). The onWillStart closure used [weak self] while its enclosing Task closure already captures self strongly (matching generateAIResponseWithTools's existing convention, which uses no weak self anywhere) — mixing capture strength between nested closures over the same self is exactly what Swift 6's new #ImplicitStrongCapture diagnostic flags. Not a functional bug (self was already kept alive for the Task's whole duration regardless), just inconsistent with this file's own pattern. Removed the pointless weak capture.
This commit is contained in:
@@ -2019,8 +2019,13 @@ Don't narrate future actions ("Let me...") - just use the tools.
|
||||
// pattern already proven in AppleDynamicToolTests' CallbackRecorder).
|
||||
let collector = ToolCallDetailCollector()
|
||||
|
||||
let onWillStart: AppleToolCallWillStart = { [weak self] toolName in
|
||||
self?.currentToolActivity = String(localized: "🔧 Calling: \(toolName)")
|
||||
// No [weak self] here: the enclosing Task already captures self strongly (same
|
||||
// convention generateAIResponseWithTools uses) — a weak capture in this nested closure
|
||||
// wouldn't protect against anything self isn't already kept alive for, and mixing
|
||||
// strengths between nested closures capturing the same self is what
|
||||
// #ImplicitStrongCapture flags.
|
||||
let onWillStart: AppleToolCallWillStart = { toolName in
|
||||
self.currentToolActivity = String(localized: "🔧 Calling: \(toolName)")
|
||||
}
|
||||
let onDidFinish: AppleToolCallDidFinish = { detail in
|
||||
collector.details.append(detail)
|
||||
|
||||
Reference in New Issue
Block a user