Skip to content

feat(agent-core-v2): make the AgentSwarm launch ramp configurable - #3125

Open
Jiliac wants to merge 1 commit into
MoonshotAI:mainfrom
Jiliac:fix/configurable-swarm-ramp
Open

feat(agent-core-v2): make the AgentSwarm launch ramp configurable#3125
Jiliac wants to merge 1 commit into
MoonshotAI:mainfrom
Jiliac:fix/configurable-swarm-ramp

Conversation

@Jiliac

@Jiliac Jiliac commented Aug 20, 2026

Copy link
Copy Markdown

Related Issue

None — opened proactively. Note: CONTRIBUTING states external feature PRs require prior maintainer approval via an issue; happy to open an issue first and link it here if preferred.

Problem

The AgentSwarm launch ramp is hardcoded: 5 subagents launch immediately, then one more every 700 ms. Users running high-concurrency inference backends (e.g. a self-hosted vLLM server sized for tens of parallel sequences) cannot raise it. The existing KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY env var only caps concurrent subagents — it does not change the launch ramp, and leaving it unset is already uncapped.

What changed

  • New [swarm] config section owned by the swarm feature and registered through the v2 config registry (registerConfigSection):
    • initial_launch_limit (default 5) — subagents launched immediately when a batch starts
    • launch_interval_ms (default 700) — delay between subsequent launches; 0 launches the rest without delay
  • AgentRunBatch accepts both as options; the previous constants survive as the exported defaults, so behavior is unchanged for users who do not opt in.
  • SessionSwarmService reads the section through IConfigService on each run, so edits apply to new swarms without a restart.
  • The rate-limit backoff path is untouched — the settings only shape the normal launch phase.
  • Scope: v2 engine only (the CLI and kap-server both run v2; v1 agent-core is being phased out and keeps the hardcoded ramp).
  • Tests: two new scheduling-contract tests (configured 24-immediate/0 ms launch, custom 2/100 pacing); the existing 5/700 default test is unchanged and still passes.
  • Regenerated config-manifest.toml; documented [swarm] in the EN/ZH config reference and linked it from the AgentSwarm tool reference.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • 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.

Add a [swarm] config section (initial_launch_limit, launch_interval_ms)
owned by the swarm feature and read through IConfigService, replacing the
hardcoded 5-immediate / 700ms-interval constants as defaults.
@changeset-bot

changeset-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c42ecf3

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

This PR includes changesets to release 1 package
Name Type
@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

@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: c42ecf3ebe

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


export const SwarmConfigSchema = z.object({
initialLaunchLimit: z.number().int().min(1).optional(),
launchIntervalMs: z.number().int().min(0).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 Reject launch intervals above Node's timer limit

When launch_interval_ms is 2147483648 or larger, this schema accepts it, but the value is passed directly to setTimeout in AgentRunBatch; on the supported Node.js 24 runtime, an overflowing timeout is reduced to 1 ms. A user requesting a very slow ramp therefore gets an almost immediate ramp instead. Cap the schema at the runtime's maximum timer delay or schedule through the existing setClampedTimeout helper.

Useful? React with 👍 / 👎.

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