Ashfaqbs opened a new pull request, #1071: URL: https://github.com/apache/flink-agents/pull/1071
Fixes #1070. ## Problem When a job cancellation interrupts an in-flight chat-model call, the resulting `InterruptedException` was handled the same as any other model failure: - `ChatModelInvoker.chatWithRetries()` caught it with the generic `catch (Exception e)` block and, under `ERROR_HANDLING_STRATEGY=RETRY`, could apply retry backoff and issue another model call after cancellation had already been requested — delaying task shutdown and firing unnecessary external requests. - `RunnerContextImpl` (`durableExecuteCompletionOnly` and `executeAndFinalizeCurrentCall`) recorded the interruption as a completed durable success/failure before rethrowing it. With an `ActionStateStore` configured, that meant a stale interruption from a cancelled attempt could be replayed as a terminal result after recovery instead of the call being re-executed. ## Fix Added an `InterruptedException`-specific catch ahead of the generic failure handling in both places: - `ChatModelInvoker.chatWithRetries()` now restores the thread's interrupt status and rethrows immediately, skipping the retry/backoff branch entirely, regardless of `FAIL`, `RETRY`, or `IGNORE`. - `RunnerContextImpl.durableExecuteCompletionOnly()` and `executeAndFinalizeCurrentCall()` now restore the interrupt status and rethrow without calling `recordDurableCompletion`/`finalizeCurrentCall`, so the durable slot is left unfinished (or pending) for recovery to re-execute or reconcile instead of replaying a stale interruption. Ordinary provider/network failures are unaffected — they still go through the existing retry and durable-completion paths untouched. ## Testing - Added `ChatModelInvokerTest` (new file) covering: an interrupted call is not retried (`durableExecute` invoked exactly once) and the interrupt status is restored; an ordinary `RuntimeException` still consumes the full retry budget, to confirm normal retry behavior is unchanged. - Added two cases to `RunnerContextImplDurableExecuteTest` covering the legacy completion-only path and the pending-slot resume path: an interruption is not persisted as a durable result and the interrupt status is restored. - Verified RED before the fix (`git stash` on the two source files, keeping the new tests) — all four new/updated cases failed as expected, then GREEN after restoring the fix. - Full `plan` module suite: 288/290 passing; the 2 failures are pre-existing `BashToolTest` cases unrelated to this change (they require a working WSL bash on this Windows environment and fail the same way on `main` before this diff). - Full `runtime` module suite: passing. - `spotless:check` clean on both modules. Generated-by: Claude Code 2.1.226 (Claude Opus 4.6) --- This fix follows from my own diagnosis of the bug. I used AI tooling for exploration and testing, directing it toward the change I had in mind. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
