Skip to content

feat: support a configurable secondary model for subagents#2064

Draft
7Sageer wants to merge 1 commit into
MoonshotAI:mainfrom
7Sageer:feat-subagent-k27
Draft

feat: support a configurable secondary model for subagents#2064
7Sageer wants to merge 1 commit into
MoonshotAI:mainfrom
7Sageer:feat-subagent-k27

Conversation

@7Sageer

@7Sageer 7Sageer commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No GitHub issue — the requirement comes from an internal design doc ("主子 Agent 模型定义", Moonshot Feishu wiki). The problem is explained below.

Problem

Subagents always inherit the calling agent's model. Users who want to save cost or capacity on a strong primary model have no way to run subagents on a cheaper secondary model: there is no configuration surface for a per-purpose model, and the main agent cannot choose a different model per spawn. Fork agents must keep using the parent's model (they share context), so the choice only applies to fresh spawns.

What changed

  • New [subagent] model / effort fields in config.toml, with KIMI_SUBAGENT_MODEL / KIMI_SUBAGENT_EFFORT env overrides (env wins and is never persisted). The value is any configured model alias, so the secondary model is not limited to Kimi models.
  • When configured, Agent / AgentSwarm spawns bind the secondary model (and optional effort) by default; both tools gain a model parameter ("subagent" | "primary") and advertise the two concrete aliases in their descriptions so the main agent can pick per spawn. When nothing is configured, spawning behavior is byte-for-byte unchanged (subagents inherit the caller's model).
  • Resumed subagents now keep the model recorded in their own wire journal instead of being realigned to the parent agent's current model — the old invariant contradicts per-subagent models. Resuming a subagent requires the model it was created with to still be configured.
  • Spawn failures caused by an invalid secondary model alias are wrapped with a pointer to the config knob; other creation failures pass through untouched.
  • Fork agents, /init, main-model resolution, and legacy agent-core are unchanged. No automatic default secondary model is wired in this phase (explicit configuration only).
  • Docs updated (config-files, env-vars, tools reference; en + zh). Tests were added to existing test files only. A changeset is included.

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 Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d2ce676

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

This PR includes changesets to release 4 packages
Name Type
@moonshot-ai/agent-core-v2 Minor
@moonshot-ai/kimi-code Minor
@moonshot-ai/kap-server Patch
@moonshot-ai/klient 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

@7Sageer
7Sageer force-pushed the feat-subagent-k27 branch from 2dc8bf8 to d2ce676 Compare July 22, 2026 15:02
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