Skip to content

feat: allow configuring a separate model for subagents (#568)#707

Open
wintrover wants to merge 1 commit into
MoonshotAI:mainfrom
wintrover:feat/subagent-model-override
Open

feat: allow configuring a separate model for subagents (#568)#707
wintrover wants to merge 1 commit into
MoonshotAI:mainfrom
wintrover:feat/subagent-model-override

Conversation

@wintrover

Copy link
Copy Markdown

Summary

Adds support for configuring a separate model for subagents via config.toml, resolving #568.

Changes

packages/agent-core/src/config/schema.ts

  • Added SubagentConfigSchema with optional model field
  • Added subagents field to both KimiConfigSchema and KimiConfigPatchSchema

packages/agent-core/src/session/subagent-host.ts

  • Added resolveSubagentModel() method with 3-level priority resolution
  • Replaced all 4 hardcoded parent.config.modelAlias assignments in:
    • configureChild()
    • resume()
    • retry()
    • startBtw()

Priority Order

Priority Source Example
1 (highest) KIMI_SUBAGENT_MODEL env var KIMI_SUBAGENT_MODEL=mimo-v2.5
2 [subagents].model in config.toml [subagents]\nmodel = "mimo-v2.5"
3 (default) Parent agent model Inherited from parent

Usage

# ~/.kimi-code/config.toml
[subagents]
model = "mimo-v2.5"

Design Decisions

  • Minimal change: Only 2 files modified, 25 lines added, 5 removed
  • Backward compatible: Without [subagents] section, behavior is identical to current (inherits parent model)
  • Env var override: KIMI_SUBAGENT_MODEL allows per-session override without config file changes
  • No breaking changes: SubagentConfigSchema is optional in both config and patch schemas
  • startBtw() also respects the override: Side-channel conversations use the configured subagent model

Closes #568

Add [subagents] config section to config.toml that allows overriding
the model used by subagents independently from the parent agent.

Priority order:
1. KIMI_SUBAGENT_MODEL env var (highest)
2. [subagents].model in config.toml
3. Parent agent model (default fallback)

Closes MoonshotAI#568
@changeset-bot

changeset-bot Bot commented Jun 13, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1fc9602

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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: 1fc96025d6

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

if (envModel) return envModel;

// Config override from [subagents] section
const subagentModel = this.session.options.config?.subagents?.model;

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 Honor [subagents] when loading TOML

When users set [subagents] model = "..." in config.toml, this lookup never sees it: transformTomlData only preserves explicitly handled plain-object sections and has no subagents branch, so the table is dropped during config load; the write path also lacks a subagents section. As a result, the advertised config option silently falls back to the parent model unless KIMI_SUBAGENT_MODEL is set.

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.

Feature: Allow configuring a separate model for subagents

1 participant