Skip to content

fix: clean up background tasks on session exit#641

Merged
7Sageer merged 2 commits into
MoonshotAI:mainfrom
7Sageer:fix/headless-background-cleanup
Jun 11, 2026
Merged

fix: clean up background tasks on session exit#641
7Sageer merged 2 commits into
MoonshotAI:mainfrom
7Sageer:fix/headless-background-cleanup

Conversation

@7Sageer

@7Sageer 7Sageer commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue; this is a focused fix for benchmark/headless sessions that should not leave Kimi-managed background tasks running after the session exits. The problem is explained below.

Problem

Headless sessions can start long-running Bash commands as Kimi-managed background tasks. The previous default kept those tasks alive when the session closed, which is surprising in benchmark and automation environments: the main kimi -p process can exit while its managed background work continues to hold resources and delay the outer runner.

What changed

  • Change the session-close default so Kimi-managed background tasks are stopped unless keep-alive is explicitly enabled.
  • Preserve the opt-in escape hatch with background.keepAliveOnExit = true or KIMI_CODE_BACKGROUND_KEEP_ALIVE_ON_EXIT=true.
  • Update lifecycle coverage for the new default and explicit keep-alive opt-in.
  • Update English and Chinese configuration docs, plus a major changeset for the behavior change.

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.

@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2b70029

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

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/agent-core Patch
@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 Jun 11, 2026

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

commit: 2b70029

@7Sageer 7Sageer force-pushed the fix/headless-background-cleanup branch from 2fea3e7 to 1178d1e Compare June 11, 2026 03:25
Change versioning for agent-core and kimi-code to patch.

Signed-off-by: 7Sageer <12210216@mail.sustech.edu.cn>
@7Sageer 7Sageer merged commit 30459af into MoonshotAI:main Jun 11, 2026
8 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 11, 2026
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