Skip to content

feat: add default_swarm_mode config and remove the swarm mode enter reminder - #5352

Merged
sailist merged 3 commits into
release/2026-11-25from
feat-444-11-24-default-swarm-mode
Nov 24, 2026
Merged

sailist merged 3 commits into
release/2026-11-25from
feat-444-11-24-default-swarm-mode

Conversation

@sailist

@sailist sailist commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Requirement or Bug

Users who want every session to run with swarm mode have to turn it on manually (/swarm or the composer toggle) in each new session — there is no config counterpart to default_plan_mode. Separately, turning swarm mode on injects a long enter reminder into the conversation every time, which is pure noise for anyone who keeps swarm on by default. This PR adds default_swarm_mode (mirroring default_plan_mode across every config surface) and removes the swarm enter reminder entirely.

Bug Reproduction Steps

N/A (feature PR).

Root Cause

N/A (feature PR).

Code Changes

Two themes, one commit each. The branch is rebased onto the release/2026-11-25 tip.

1. default_swarm_mode config (feat commit). A new top-level boolean config (default false), registered next to the existing [swarm] section in packages/agent-core-v2/src/features/swarm/configSection.ts. The single enforcement point is session creation in sessionLifecycleService.create(): when the config is true, the main agent enters swarm mode with the manual trigger (the only persistent trigger — task auto-exits at turn end, tool is rejected). This one choke point covers TUI, kimi -p, ACP, and SDK session creation. The config is then mirrored across every surface default_plan_mode already occupies: node-sdk (KimiConfigSchema / patch schema / TOML writer / v2 config domains), the KAP host config API (GET/POST /api/v1/config, schema docs regenerated via pnpm qa:refresh schema, HOST_CONTRACT digest re-pinned with apiLevel unchanged since the field is additive-optional), app-core daemon wire/mappers/client/types, a desktop Settings toggle with en/zh copy, TUI lazy appState hydration, the regenerated config manifest, and the bilingual config docs. Unlike default_plan_mode, the default is applied in non-interactive mode (kimi -p) — a deliberate product decision: it makes swarms available in print/ACP sessions, gated behind the explicit opt-in config.

2. Swarm enter reminder removal (refactor commit). SwarmInjection, enter-reminder.md, and the swarmReminderDelivered replayable state (plus its tests and checkpoint exemption) are deleted; state/wire manifests regenerated. Old sessions replay safely: state is rebuilt by folding events (the SwarmModeEnter/Exit event classes stay), and previously recorded swarm_mode injection messages remain in history as plain context — pinned by the reworked test replays sessions that recorded a legacy enter reminder as plain history.

Two enabling fixes surfaced during the work:

  • ContextAppendMessage (durable) was only ever registered as a side effect of the removed fold ("fold = register"), so deleting the fold silently dropped context.append_message from the wire manifest. It is now registered explicitly at its declaration, matching the existing mirrorAgentRun.ts pattern; runtime behavior is unchanged.
  • check:duplication flagged the response-vs-patch schema self-clones in rest-config.ts and node-sdk schema.ts once the new field shifted their fingerprints. Fixed in code by extracting the shared field sets (configFieldsSchema + .extend(), sessionModeFields spread) — validation behavior is identical and the contract digest did not move.

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
New session with default_swarm_mode = true starts outside swarm mode starts in swarm mode (manual trigger), including kimi -p and ACP sessions nobody — new opt-in config, default false keeps current behavior leave unset / false
Swarm mode turn-on (/swarm, composer toggle) injects an enter reminder (workflow guidance) into the conversation no injection; the model relies on the AgentSwarm tool description users/models who benefited from the injected guidance; sessions recorded by older versions keep the old messages as plain history none — removal explicitly approved by the maintainer in this PR
swarmReminderDelivered replayable state present in state/wire manifests removed consumers of the generated manifest docs manifests regenerated in the same PR
Host config API (GET/POST /api/v1/config) no default_swarm_mode field optional field accepted and returned additive; old clients unaffected (apiLevel stays 1) n/a
Desktop Settings no swarm default toggle "Swarm mode by default" toggle (en/zh) additive n/a
Swarm availability in kimi -p / ACP unavailable (only interactive users could enable swarm) available when default_swarm_mode = true config-gated expansion leave unset

Test coverage per row: TUI startup hydration cases extended (defaultSwarmMode → swarmMode in appState, both cold start and session-less login); new defaultSwarmMode config section registration test in core config tests; legacy-replay test for old sessions; kap-server apiSurface (re-pinned digest) and config round-trip tests; manual kimi -p end-to-end with a temp KIMI_CODE_HOME verified swarm_mode.enter (trigger: manual) in the session wire with no reminder injection.

Deleted tests (all covered the intentionally removed injection behavior): delivers enter guidance at the first step…, delivers enter guidance only once…, keeps history on exit and delivers once for each new activation, keeps enter guidance when a later context message…, does not duplicate the enter guidance on resume…, delivers once after replay when a new activation is still pending, and the swarm context reconciliation end-to-end case. Continuing coverage: mode transitions, telemetry, wire persistence, tool-trigger rejection, batch guarding tests are untouched, and the legacy-replay test pins the compat story for histories written by older versions.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve). — internal task, no issue
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset. — 6 changesets included
  • Ran gen-docs skill, or this PR needs no doc update. — config-files.md (en/zh) updated in this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T10:31:52.508820Z d8545f3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 24, 2026 •

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

commit: d8545f3

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee4400252f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

"@moonshot-ai/kimi-code": minor
---

Add the `default_swarm_mode` config option: new sessions start in swarm mode by default. Unlike `default_plan_mode`, it also applies in non-interactive mode (`kimi -p`).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add product release notes for removed swarm guidance

For CLI and desktop swarm users, the product changesets only announce the new default-mode setting, while this same diff removes the enter reminder and its workflow guidance. The only changeset that mentions this loss targets @moonshot-ai/agent-core-v2, so the CLI and desktop release notes will not tell affected users that the model behavior changed; add separate product changesets for @moonshot-ai/kimi-code and kimi-code-app that state the guidance removal.

AGENTS.md reference: AGENTS.md:L171-L171

Useful? React with 👍 / 👎.

@@ -0,0 +1,5 @@
---
"@moonshot-ai/node-sdk": minor

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Target the actual SDK package in the changeset

The workspace at packages/node-sdk/package.json is named @moonshot-ai/kimi-code-sdk, and a repo-wide search finds no package named @moonshot-ai/node-sdk. This frontmatter therefore cannot associate the change with the modified SDK during release planning; replace it with the actual workspace package name so the SDK is versioned and receives the changelog entry.

Useful? React with 👍 / 👎.

Comment on lines +1156 to +1158
:model-value="configBool(config.defaultSwarmMode)"
:label="t('settings.defaultSwarmMode')"
@update:model-value="toggleConfigBoolean('defaultSwarmMode')"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply the configured default to the desktop draft mode

When a desktop or web user enables this setting with no active session, the composer still reads draftModes.swarmMode, which is initialized to false; createDraftSession only persists a truthy draft value, and DaemonKimiWebApi.createSession has no swarmMode input. The server consequently starts the first turn in swarm mode from the new global default while the pre-session UI shows it as off, and even toggling on and back off cannot express a per-session override. Hydrate the draft from the config and send the final explicit boolean when creating the session.

Useful? React with 👍 / 👎.

@@ -0,0 +1,5 @@
---
"@moonshot-ai/agent-core-v2": patch

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Version the removed state contract as breaking

Removing swarmReminderDelivered from the generated AgentStateSnapshot contract breaks consumers that compile against or inspect that state key, but this entry requests only a patch bump and the companion agent-core entry raises the effective release only to minor. Either retain a compatibility representation or obtain the required approval and release this contract removal as a major change.

AGENTS.md reference: AGENTS.md:L90-L90

Useful? React with 👍 / 👎.

@changeset-bot

changeset-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d8545f3

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

This PR includes changesets to release 11 packages
Name Type
@moonshot-ai/kimi-code Minor
@moonshot-ai/agent-core-v2 Minor
kimi-code-app Minor
@moonshot-ai/kap-server Minor
@moonshot-ai/kimi-code-sdk Minor
@moonshot-ai/acp-server Patch
@moonshot-ai/klient Patch
@moonshot-ai/migration-legacy Patch
@moonshot-ai/kimi-code-product Patch
@moonshot-ai/remote-control Patch
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

@sailist
sailist merged commit 2b1b095 into release/2026-11-25 Nov 24, 2026
36 of 37 checks passed
@sailist
sailist deleted the feat-444-11-24-default-swarm-mode branch November 24, 2026 12:29
sailist added a commit that referenced this pull request Nov 25, 2026
…nder

Reverts 2b1b095 (#5352). Keeps the shared config schema field extraction in node-sdk and kap-server without the swarm keys.
sailist added a commit that referenced this pull request Nov 25, 2026
…nder (#5409)

Reverts 2b1b095 (#5352). Keeps the shared config schema field extraction in node-sdk and kap-server without the swarm keys.
kimi-agent-bot pushed a commit that referenced this pull request Nov 25, 2026
…eminder (#5352)

* feat: add default_swarm_mode config to start new sessions in swarm mode

* refactor(agent-core-v2): remove the swarm mode enter reminder

* chore: address changeset review findings
kimi-agent-bot pushed a commit that referenced this pull request Nov 25, 2026
…nder (#5409)

Reverts 2b1b095 (#5352). Keeps the shared config schema field extraction in node-sdk and kap-server without the swarm keys.
kimi-agent-bot pushed a commit that referenced this pull request Nov 25, 2026
…eminder (#5352)

* feat: add default_swarm_mode config to start new sessions in swarm mode

* refactor(agent-core-v2): remove the swarm mode enter reminder

* chore: address changeset review findings
kimi-agent-bot pushed a commit that referenced this pull request Nov 25, 2026
…nder (#5409)

Reverts 2b1b095 (#5352). Keeps the shared config schema field extraction in node-sdk and kap-server without the swarm keys.
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.

2 participants