← Back to Pull requests

[plan][runtime] Do not retry or persist interrupted chat calls on cancellation #1071

Closed
unknown closed this pull request without merging on Sep 09, 2026 08:14 UTC
View on GitHub
unknown unknown commented on Aug 30, 2026 02:09 UTC
Author

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: 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.

    Diff: 353 lines (+264 / -89) across 4 files Reviewer: weiqingy Review duration: 14765m
    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
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.5% (MEDIUM) · Higher = larger blast radius
    42.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.4% · Safe to merge
    18.4%