feat: add default_swarm_mode config option - #2670
Conversation
🦋 Changeset detectedLatest commit: 563903d The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 |
When default_swarm_mode = true is set in config.toml, every freshly created session enters swarm mode (trigger 'manual', equivalent to an explicit /swarm on). Resumed sessions restore their own swarm state from records and never re-apply the default; /swarm off still overrides per session. Mirrors the existing default_plan_mode behavior end to end: v1 (agent-core) config schema/toml/configService plus the createSession hook, v2 (agent-core-v2) config section registration plus the sessionLifecycle hook, wire schemas (protocol, kap-server), node-sdk config mapper, TUI footer hydration, and docs. Refs MoonshotAI#720.
cb43e29 to
6976782
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6976782ba8
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "@moonshot-ai/kimi-code": minor | ||
| "@moonshot-ai/kimi-code-sdk": minor |
There was a problem hiding this comment.
Use patch bumps for this config addition
When this changeset is consumed during release, both packages will receive minor versions even though default_swarm_mode only adds a global default for the existing swarm feature. The required gen-changesets policy classifies additions to an existing feature's configuration as patch, so change both frontmatter entries to patch to avoid unnecessary minor releases.
AGENTS.md reference: AGENTS.md:L82-L83
Useful? React with 👍 / 👎.
| @@ -0,0 +1,100 @@ | |||
| import { mkdtemp, mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises'; | |||
There was a problem hiding this comment.
Consolidate the swarm bootstrap tests
This creates a separate harness test file even though packages/agent-core/test/harness/plan-mode-session.test.ts already covers the corresponding mode-bootstrap lifecycle and this file duplicates its rig and scenario matrix. Move these swarm cases into that existing test file so coverage for the same component is not fragmented.
AGENTS.md reference: AGENTS.md:L59-L60
Useful? React with 👍 / 👎.
Review follow-ups: defaulting an existing feature's config is a patch bump per the gen-changesets policy, and the swarm bootstrap cases belong in the existing plan-mode-session harness suite (AGENTS.md test placement convention).
Related Issue
Resolve #720
Problem
See linked issue.
config.tomlsupportsdefault_plan_modebut has no swarm equivalent, so users who want swarm mode in every session have to remember to type/swarm onat the start of each one.What changed
Adds a
default_swarm_modeboolean config option (defaultfalse— no behavior change unless opted in) that mirrorsdefault_plan_modeend to end:agent-core): config schema (+ patch schema), TOML round-trip scalar, config-service response mapping, and acreateSessionhook that enters swarm mode on fresh sessions. Resumed sessions restore their own swarm state from wire records and never re-apply the default.agent-core-v2): newagent/swarm/configSection.ts(registered,defaultValue: false), applied inSessionLifecycleService.create; config manifest regenerated.default_swarm_modeadded to the protocol and kap-server REST config schemas (response + patch) and the node-sdk v2 config mapper.config-files.md(en/zh) complete-example block and field table.Why this approach: it follows the existing
default_plan_modepattern 1:1, so the behavior is consistent wherever sessions are created (TUI, SDK, kap-server, ACP). The entry uses the'manual'trigger —task/toolswarm entries auto-exit at turn end, which would make a session-level default pointless;'manual'is exactly what/swarm ondoes, and a per-session/swarm offpersists across resume via the wire records.Testing: new v2 lifecycle bootstrap cases (fresh/absent/resume, enter-with-
'manual'), a v1 wire-record harness test (same matrix from a real config.toml), config parse + v1/v2 parity assertions, and TUI hydration. Full suites green for all touched packages (agent-core,agent-core-v2,node-sdk,protocol,kap-server,kimi-code), plus cleantypecheckandlint.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.