Skip to content

fix(agent-core-v2): let session archive proceed after a failed resume - #3139

Merged
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:bug-061-08-20-archive-resume-failure
Aug 20, 2026
Merged

fix(agent-core-v2): let session archive proceed after a failed resume#3139
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:bug-061-08-20-archive-resume-failure

Conversation

@sailist

@sailist sailist commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

None — the problem is explained below (no tracking issue exists yet).

Problem

Archiving a session can fail with the error of an earlier, unrelated resume attempt: after a session's workspace is unregistered and its directory deleted, opening the session fails with workspace root ... does not exist, and every subsequent :archive call for that session fails with the same error (40409) until the server restarts.

Root cause: a failed resume is cached by SessionManager and rethrown by whenResumeSettled. setSessionArchived awaits that settle before classifying the session as live or cold, so the stale resume error aborts the archive before it ever reaches the cold path — even though cold archive only rewrites session metadata in the home directory and never touches the workspace.

What changed

  • setSessionArchived still waits for an in-flight resume to settle (required for a correct live/cold classification) but no longer rethrows a historical resume failure: a failed resume leaves no live handle, so falling through to the cold metadata path is the correct behavior. Live sessions are unaffected and still go through the full lifecycle chain (agents drain, scope disposal, events).
  • Added a kap-server regression test: a cold session whose resume failed because the workspace root is gone archives successfully via :archive.
  • Inverted the agent-core-v2 unit test that pinned the old "propagate failed resumes to the next settle" behavior for archive; it now asserts the failed resume is ignored and the item is cold-classified.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (none exists; problem explained 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.

A failed resume is cached by SessionManager and rethrown from
whenResumeSettled, so archiving a session whose workspace is gone
failed with the stale resume error even though cold archive only
rewrites session metadata. Swallow the settle failure: still wait for
an in-flight resume before the live/cold classification, but fall
through to the cold metadata path after a failed one.
@changeset-bot

changeset-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ceaa3e6

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

@pkg-pr-new

pkg-pr-new Bot commented Aug 20, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@ceaa3e6
npx https://pkg.pr.new/@moonshot-ai/kimi-code@ceaa3e6

commit: ceaa3e6

@sailist
sailist merged commit 381142a into MoonshotAI:main Aug 20, 2026
16 checks passed
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.

1 participant