Feature: Allow configuring a separate model for subagents
Summary
Currently, subagents always inherit the parent agent's model — there is no way to configure them to use a different model than the main agent.
Current behavior (source-verified)
In packages/agent-core/src/session/subagent-host.ts, the configureChild method explicitly copies the parent's modelAlias:
// A subagent always inherits the parent agent's model.
child.config.update({
cwd: parent.config.cwd,
modelAlias: parent.config.modelAlias, // ← hardcoded inheritance
thinkingLevel: parent.config.thinkingLevel,
});
The same pattern appears in resume(), retry(), and startBtw().
Additionally:
- Config schema (
config/schema.ts):KimiConfigSchemahas no subagent-model-related field - Agent tool input (
tools/builtin/collaboration/agent.ts):AgentToolInputSchemaaccepts nomodelparameter - Subagent profile schema (
profile/types.ts):RawSubagentProfileSchemaonly hasdescription
Desired behavior
Allow users to optionally specify a different model for subagents, so they can e.g.:
- Use a powerful/expensive model (
kimi-k2p6-turbo) for the main agent - Use a lighter/faster/cheaper model (
glm-5v-turbo) for coder/explore/plan subagents
Suggested approach
One clean option would be a new config section like:
[subagents]
model = "zai-coding-plan/glm-5v-turbo" # default for all subagent types
[subagents.coder]
model = "zai-coding-plan/glm-5v-turbo"
[subagents.explore]
model = "zai-coding-plan/glm-4.5-air" # even lighter for read-only tasks
This would require changes in:
KimiConfigSchema— add[subagents]table(s)AgentToolInputSchema— optional per-callmodeloverrideRawSubagentProfileSchema/ profile YAML — optional per-profilemodelSessionSubagentHost.configureChild()— use subagent-specific model instead of parent'smodelAlias
Use case / motivation
Users with access to multiple models often want to allocate compute strategically:
- The main agent drives high-level reasoning → benefits from a stronger model
- Subagents perform focused, scoped tasks (file reading, grep, targeted edits) → work well with faster/cheaper models
- This can significantly reduce cost and latency for sessions that spawn many subagents
Environment
- OS: Linux
- Version: kimi-code v0.11.0
🛠️ Working Workaround: Runtime Subagent Model Override
While this issue gets addressed in source, here's a working runtime workaround that patches the bundled main.mjs to support a [subagents] config section in config.toml.
What it does
Injects a resolveSubagentModel() function into configureChild(), resume(), retry(), and startBtw() — the 4 call sites where parent.config.modelAlias is hardcoded.
Setup
1. Add [subagents] to ~/.kimi-code/config.toml:
[subagents]
model = "mimo-v2.5"
2. Create the patch script at ~/.kimi-code/patches/apply.sh:
#!/bin/bash
set -euo pipefail
MAIN_MJS="$HOME/.npm-global/lib/node_modules/@moonshot-ai/kimi-code/dist/main.mjs"
[[ ! -f "$MAIN_MJS" ]] && { echo "main.mjs not found"; exit 1; }
FUNC='function resolveSubagentModel(parentAlias){try{const env=process.env;if(env.KIMI_SUBAGENT_MODEL)return env.KIMI_SUBAGENT_MODEL;const fs=require("fs"),os=require("os"),path=require("path");const home=env.KIMI_CODE_HOME||path.join(os.homedir(),".kimi-code");const content=fs.readFileSync(path.join(home,"config.toml"),"utf8");const subMatch=content.match(/\[subagents\]\s*\n([\s\S]*?)(?=\n\[|\s*$)/);if(subMatch){const modelMatch=subMatch[1].match(/^model\s*=\s*"([^"]+)"/m);if(modelMatch)return modelMatch[1]}}catch(e){}return parentAlias}'
# Backup once
[[ ! -f "${MAIN_MJS}.bak."* ]] && cp "$MAIN_MJS" "${MAIN_MJS}.bak.$(date +%Y%m%d_%H%M%S)"
PATCHED=0
for FN in configureChild resume retry startBtw; do
if ! grep -q "resolveSubagentModel(${FN}\|${FN}.*resolveSubagentModel" "$MAIN_MJS" 2>/dev/null; then
if perl -0777 -i -pe "s/(async function ${FN}\(parent\)\{[^}]*?)parent\.config\.modelAlias/\1resolveSubagentModel(parent.config.modelAlias)/g" "$MAIN_MJS" 2>/dev/null; then
[[ $(grep -c "resolveSubagentModel(parent.config.modelAlias)" "$MAIN_MJS" | head -1) -gt 0 ]] && PATCHED=1
fi
fi
done
if [[ $PATCHED -eq 1 ]]; then
if ! grep -q "^function resolveSubagentModel" "$MAIN_MJS"; then
perl -0777 -i -pe "s/(const esmRequire = )/${FUNC}\n\1/" "$MAIN_MJS"
fi
echo "✅ Patched + function injected"
fi
chmod +x "$MAIN_MJS"
# Restore wrapper symlink if needed
WRAPPER="$HOME/.npm-global/bin/kimi-wrapper.sh"
KIMI_BIN="$HOME/.npm-global/bin/kimi"
if [[ -f "$WRAPPER" ]]; then
CURRENT_TARGET=$(readlink "$KIMI_BIN" 2>/dev/null || echo "")
[[ "$CURRENT_TARGET" != "kimi-wrapper.sh" ]] && ln -sf kimi-wrapper.sh "$KIMI_BIN"
fi
3. Create auto-restore wrapper at ~/.npm-global/bin/kimi-wrapper.sh:
#!/bin/bash
PATCH_SCRIPT="$HOME/.kimi-code/patches/apply.sh"
MAIN_MJS="$HOME/.npm-global/lib/node_modules/@moonshot-ai/kimi-code/dist/main.mjs"
if [[ -f "$PATCH_SCRIPT" && -f "$MAIN_MJS" ]]; then
if ! grep -q "resolveSubagentModel" "$MAIN_MJS" 2>/dev/null; then
bash "$PATCH_SCRIPT" 2>&1 || true
fi
fi
exec node "$MAIN_MJS" "$@"
4. Make kimi use the wrapper:
chmod +x ~/.kimi-code/patches/apply.sh ~/.npm-global/bin/kimi-wrapper.sh
ln -sf kimi-wrapper.sh ~/.npm-global/bin/kimi
bash ~/.kimi-code/patches/apply.sh
How it works
- On each
kimiinvocation, the wrapper checks ifmain.mjsis still patched - After
kimi upgrade(which overwritesmain.mjs), the next invocation auto-reapplies the patch - Config priority:
KIMI_SUBAGENT_MODELenv var >[subagents].modelin config.toml > parent model (fallback) - Optional per-type override support:
[subagents.explore],[subagents.plan],[subagents.coder]sections can be added toresolveSubagentModel()
Scope options
| Config | Behavior |
|---|---|
model = "mimo-v2.5" |
All subagents use mimo-v2.5 |
KIMI_SUBAGENT_MODEL=mimo-v2.5 |
Env var override (highest priority) |
| Default (no config) | Subagents inherit parent model |
This is a practical workaround until the proper TypeScript source change lands in a release. Happy to help with the source-level PR if needed!
Strongly +1 this. This is not just a nice-to-have cost optimization; it is a strategic feature that would meaningfully expand Kimi Code's addressable user base.
Real-world use case: I want to run the main agent on a top-tier reasoning model like Claude 4.x for high-level architecture and planning, while dispatching subagents (coder/explore/plan) to Kimi or DeepSeek for the actual implementation work. Each layer is best served by a different model's strengths:
- Main agent: strongest reasoning / longest context for coordination.
- Subagents: fast, cheap, coding-focused models for scoped read/edit/grep tasks.
Without per-subagent model selection, the only workaround is to run separate manual sessions and copy results back, which breaks the unified agent-loop experience that makes Kimi Code compelling.
The user experience of Kimi Code is already comparable to Claude Code. Adding this would remove a major architectural limitation and make multi-model, multi-agent workflows practical out of the box. Would love to see this prioritized.
+1 if we have a superior model do the workflow management, and little models do mechanical work it becomes much cheaper, and faster without compromise in any quality. We shall definitely have this feature.