Ensures aborted AI generation (timeout, user-stop, displacement, retries) actually tears down the in-flight agent session instead of only rejecting the Promise.race waiter, since provider SDKs may ignore AbortSignal.
- Add a once-only onAbort teardown hook to GenerationGuard, invoked for timeout, user-stop, and displaced abort causes so consumers can dispose their in-flight session exactly once.
- Give planning's local generation runner (runGenerationWithTimeout) the same guaranteed once-only abortTeardown for timeout, user-stop, displacement, stuck, and loop aborts, replacing the ad hoc dispose-on-timeout-only logic.
- Forward the AbortSignal into planning's history-replay prompt, turn prompts, and JSON-parse-retry prompts, and short-circuit with createAbortError() when the signal is already aborted before/after each prompt call.
- Wire subtask-breakdown's onTimeout/onUserStop handlers to the new onAbort hook instead of disposing the agent directly, keeping teardown centralized in the guard.
- Add GenerationInProgressError / TargetGenerationInProgressError handling in mission-routes to return 409 Conflict instead of a generic 500 when a generation is already running.
- Extend mission-interview and milestone-slice-interview generation paths with matching abort-forwarding and teardown behavior, plus new/expanded tests covering cancellation across timeout, user-stop, displacement, and retry paths.
- Add a patch changeset documenting the fix for @runfusion/fusion.
Files changed:
.changeset/harden-generation-abort.md | 7 ++
.../src/__tests__/ai-session-timeout.test.ts | 41 +++++--
.../__tests__/milestone-slice-interview.test.ts | 72 ++++++++++++-
.../src/__tests__/mission-interview.test.ts | 64 ++++++++++-
.../planning-generation-cancellation.test.ts | 82 ++++++++++++++
.../src/__tests__/subtask-breakdown.test.ts | 21 +++-
packages/dashboard/src/ai-session-timeout.ts | 33 +++++-
.../dashboard/src/milestone-slice-interview.ts | 120 +++++++++++++++++++--
packages/dashboard/src/mission-interview.ts | 119 ++++++++++++++++++--
packages/dashboard/src/mission-routes.ts | 12 +++
packages/dashboard/src/planning.ts | 70 +++++++++---
packages/dashboard/src/subtask-breakdown.ts | 10 +-
12 files changed, 589 insertions(+), 62 deletions(-)
Fusion-Task-Id: FN-7951
Fusion-Task-Lineage: debcd6a9-f54e-4ef3-87e1-4f06be0b5f64
Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>