Skip to content

feat: configurable default swarm mode#722

Open
meymchen wants to merge 2 commits into
MoonshotAI:mainfrom
meymchen:feat/720-configurable-default-swarm-mode
Open

feat: configurable default swarm mode#722
meymchen wants to merge 2 commits into
MoonshotAI:mainfrom
meymchen:feat/720-configurable-default-swarm-mode

Conversation

@meymchen

@meymchen meymchen commented Jun 13, 2026

Copy link
Copy Markdown

Related Issue

Resolve #720

Problem

See linked issue.

What changed

  • Added defaultSwarmMode to the agent-core config schema, allowing users to set default_swarm_mode in config.toml.
  • KimiCore.createSessionWithOverrides now applies options.swarmMode ?? config.defaultSwarmMode for new sessions.
  • Exposed swarmMode in the SDK CreateSessionOptions and the core CreateSessionPayload.
  • Added --swarm / --no-swarm CLI flags; --swarm is mutually exclusive with --prompt.
  • TUI startup resolves swarm mode from CLI flag → config default → false, creates the session with the resolved value, and prompts for permission when swarm is enabled under manual permission mode.
  • Resumed sessions only re-enable swarm when explicitly requested via --swarm.
  • Review fixes:
    • Preserve explicit --no-swarm when creating sessions instead of collapsing false back to undefined.
    • Reapply --swarm to the TUI footer/app-state after session replay hydration.
    • Serialize defaultSwarmMode into the config TOML so setConfig round-trips correctly.
  • Added tests in packages/agent-core and apps/kimi-code, and updated user docs in docs/en and docs/zh.

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 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 71d9653

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

This PR includes changesets to release 5 packages
Name Type
@moonshot-ai/agent-core Minor
@moonshot-ai/kimi-code-sdk Minor
@moonshot-ai/kimi-code Minor
@moonshot-ai/acp-adapter Patch
@moonshot-ai/migration-legacy 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 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: 98d0ae5fb7

ℹ️ 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".

Comment thread apps/kimi-code/src/tui/kimi-tui.ts Outdated
model: startup.model,
permission: startup.auto ? 'auto' : startup.yolo ? 'yolo' : undefined,
planMode: startup.plan ? true : undefined,
swarmMode: this.state.appState.swarmMode ? true : undefined,

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 Preserve explicit --no-swarm when creating sessions

When default_swarm_mode = true and the user starts the TUI with --no-swarm, createInitialAppState correctly sets appState.swarmMode to false, but this line converts that explicit false back to undefined. KimiCore.createSessionWithOverrides treats undefined as “use config.defaultSwarmMode”, so the fresh session still enters swarm mode and syncRuntimeState flips the UI back on. Pass the explicit CLI false through instead of collapsing it to undefined.

Useful? React with 👍 / 👎.

if (startup.swarm) {
const status = await session.getStatus();
if (!status.swarmMode) {
await session.setSwarmMode(true, 'manual');

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 Reapply resumed --swarm after replay hydration

When resuming with --swarm, this enables swarm in the runtime before syncRuntimeState, but finishStartup then calls sessionReplay.hydrateFromReplay, which hydrates the stale resume snapshot captured before this call and can set appState.swarmMode back to false. The existing post-replay reapply helper only restores permission and plan flags, so the footer/UI can show swarm off while the session is actually active until another status event arrives. Include swarm in the post-replay app-state reapply path.

Useful? React with 👍 / 👎.

defaultThinking: z.boolean().optional(),
defaultPermissionMode: PermissionModeSchema.optional(),
defaultPlanMode: z.boolean().optional(),
defaultSwarmMode: z.boolean().optional(),

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 Serialize defaultSwarmMode config patches

Adding defaultSwarmMode to the patch schema makes setConfig({ defaultSwarmMode: true }) validate, but writeConfigFile serializes only the keys listed in configToTomlData's scalarFields; this new key is not listed there, so the write drops it unless default_swarm_mode already existed in raw. SDK/config tooling can therefore report a successful save while the next reload starts sessions without the requested swarm default. Add defaultSwarmMode to the TOML serializer as well.

Useful? React with 👍 / 👎.

- Preserve explicit --no-swarm when creating sessions

- Reapply --swarm to UI state after session replay hydration

- Serialize defaultSwarmMode when writing config TOML

- Add regression tests for the above
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.

Feature request: configurable default swarm mode

1 participant