[plan][runtime] Do not retry or persist interrupted chat calls on cancellation #1071
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.42) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 353 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.351
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1071"
general
weight: 0.35
weiqingy
Fixes #1070.
Problem
When a job cancellation interrupts an in-flight chat-model call, the resulting
InterruptedExceptionwas handled the same as any other model failure:ChatModelInvoker.chatWithRetries()caught it with the genericcatch (Exception e)block and, underERROR_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(durableExecuteCompletionOnlyandexecuteAndFinalizeCurrentCall) recorded the interruption as a completed durable success/failure before rethrowing it. With anActionStateStoreconfigured, 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 ofFAIL,RETRY, orIGNORE.RunnerContextImpl.durableExecuteCompletionOnly()andexecuteAndFinalizeCurrentCall()now restore the interrupt status and rethrow without callingrecordDurableCompletion/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
ChatModelInvokerTest(new file) covering: an interrupted call is not retried (durableExecuteinvoked exactly once) and the interrupt status is restored; an ordinaryRuntimeExceptionstill consumes the full retry budget, to confirm normal retry behavior is unchanged.RunnerContextImplDurableExecuteTestcovering 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.git stashon the two source files, keeping the new tests) — all four new/updated cases failed as expected, then GREEN after restoring the fix.planmodule suite: 288/290 passing; the 2 failures are pre-existingBashToolTestcases unrelated to this change (they require a working WSL bash on this Windows environment and fail the same way onmainbefore this diff).runtimemodule suite: passing.spotless:checkclean on both modules.Generated-by: AI coding assistant
---
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.