feat: configurable default swarm mode#722
Conversation
🦋 Changeset detectedLatest commit: 71d9653 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
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 |
There was a problem hiding this comment.
💡 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".
| model: startup.model, | ||
| permission: startup.auto ? 'auto' : startup.yolo ? 'yolo' : undefined, | ||
| planMode: startup.plan ? true : undefined, | ||
| swarmMode: this.state.appState.swarmMode ? true : undefined, |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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
Related Issue
Resolve #720
Problem
See linked issue.
What changed
defaultSwarmModeto the agent-core config schema, allowing users to setdefault_swarm_modeinconfig.toml.KimiCore.createSessionWithOverridesnow appliesoptions.swarmMode ?? config.defaultSwarmModefor new sessions.swarmModein the SDKCreateSessionOptionsand the coreCreateSessionPayload.--swarm/--no-swarmCLI flags;--swarmis mutually exclusive with--prompt.false, creates the session with the resolved value, and prompts for permission when swarm is enabled undermanualpermission mode.--swarm.--no-swarmwhen creating sessions instead of collapsingfalseback toundefined.--swarmto the TUI footer/app-state after session replay hydration.defaultSwarmModeinto the config TOML sosetConfiground-trips correctly.packages/agent-coreandapps/kimi-code, and updated user docs indocs/enanddocs/zh.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.