agent: Fix race where compaction would be marked as cancelled (#59014)

Fixes an issue where compaction would get marked as cancelled if the
previous turn took a while to cancel. E.g. you could reproduce this when
sending a normal message, and then interrupting generation by sending
`/compact`. If the task for the prior turn took a while to complete, it
would mark the compaction triggered by `/compact` as cancelled, even
though it was not.

Release Notes:

- N/A
5c90b0664fBennet Bo Fenner committed on 6/10/2026, 9:46:00 AM· committed by GitHubparentefa2987
1 file changedLine totals unavailable