CodeTracked since May 19, 2026
Make duplicate cancel calls idempotent to eliminate spurious 409 conflicts
The pull request fixes a race in gateway run cancellation where two concurrent `cancel_run` requests could both pass the initial existence check, causing the second call to return HTTP 409 even though the run had already moved to `interrupted`. The router now re-reads run state after a failed cancel attempt and returns HTTP 202 when the run is already interrupted or already removed, while preserving 409 only for genuinely non-cancelable states.
cancel_rungateway routerTOCTOU racerun status re-check