Skip to content

fix(goal): stop daemon crash on goal pause; add graceful pause - #2802

Open
LoG1331 wants to merge 2 commits into
MoonshotAI:mainfrom
LoG1331:fix/goal-pause-crash-and-graceful-pause
Open

fix(goal): stop daemon crash on goal pause; add graceful pause#2802
LoG1331 wants to merge 2 commits into
MoonshotAI:mainfrom
LoG1331:fix/goal-pause-crash-and-graceful-pause

Conversation

@LoG1331

@LoG1331 LoG1331 commented Aug 11, 2026

Copy link
Copy Markdown

Related Issue

Resolve #2801

Problem

Pausing a goal from the web UI (kimi web / kap-server) on a session with a queued or in-flight goal continuation killed the whole server process with an uncaught AbortError: Goal continuation cancelled. Two layers combined:

  1. The continuation bookkeeping promise chain in launchContinuationTurn had no catch, so aborting a pending continuation produced an unhandled AbortError rejection.
  2. The telemetry unhandledRejection handler rethrows when it is the sole listener (print/server modes) — including AbortError, which is expected cancellation noise. The TUI survives the same action because it registers its own rejection handling; the daemon does not.

Additionally, pausing always interrupted the live goal turn mid-tool. The engine already had the preserveLiveContinuation flag (used for blocked/complete transitions) but no API surface exposed it.

What changed

  • Fix: the continuation bookkeeping chain now swallows rejections (it only cleans up bookkeeping state; real turn failures surface via turn.ended events), and the telemetry rejection handler returns early for AbortError instead of rethrowing it. Non-abort rejections still crash as before.
  • Feature: pauseGoal accepts a preserveLiveContinuation option, exposed over the session profile API as goal_control: "pause_graceful". Pausing this way lets the in-flight turn run to completion and simply stops further goal continuations.
  • Regression test: graceful pause keeps the live continuation running while the goal transitions to paused.

Verification

  • Reproduced the crash deterministically with the telemetry handler installed as sole unhandledRejection listener plus an unhandled AbortError rejection: original code exits with the reported stack shape; patched code survives. Non-abort rejections still exit.
  • test/agent/goal suite: 161/161 passing, including the new regression test.
  • End-to-end against a dev server: goal with multi-turn continuation, goal_control: "pause_graceful" mid-turn → 200 OK, the running turn completed normally (no tool interruption), goal transitioned to paused, no further continuations, daemon stayed alive.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

… continuation

Aborting a pending goal continuation rejects the bookkeeping promise chain
with an AbortError; with no catch attached, the rejection reached the
telemetry unhandledRejection handler, which rethrows when it is the sole
listener (print/server modes) — killing the kimi web process.

Swallow the rejection in the bookkeeping chain (turn failures surface via
turn.ended events) and never rethrow AbortError-shaped rejections from the
telemetry handler.
Pausing a goal interrupts the in-flight goal turn. The engine already has
the preserveLiveContinuation flag (used for blocked/complete transitions);
expose it through pauseGoal and the session profile API as
goal_control: "pause_graceful" so API clients (e.g. the web UI) can pause
without cutting the running turn off mid-tool.
@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ef0da5c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex rate limits. Please try again later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kimi web server process crashes with uncaught AbortError when pausing a goal with a queued continuation

1 participant