Subagent model and thinking-effort routing should be driven by user configuration, not by the calling LLM. This PR introduces per-workspace [subagent.<type>] bindings, a /subagent-model management command, and sticky resume behavior so that resumed subagents keep their configured model/effort instead of realigning to the parent's current model.
Related Issue
Closes (or relates to) the broader request for finer-grained subagent control:
Motivation
Delegated Agent subagents always inherit the caller's current model. Users who configure multiple model aliases in config.toml have no way to pin a subagent type (e.g. exploration) to a cheaper model, or a coding subagent to a stronger one.
PR #1841 explores letting the calling agent pick a model per call; this PR takes the opposite direction: model routing for subagents is user configuration, applied mechanically, not an LLM decision.
The rationale for keeping this mechanical rather than LLM-facing: in testing, agents reliably self-filled a model argument on resume, silently overriding the user's earlier choice. Bindings remove that discretion entirely.
What Changed
- Per-workspace bindings in
<projectRoot>/.kimi-code/local.toml under [subagent.<type>] (model, thinking_effort), following the existing workspace.additional_dir pattern.
- Interactive first-time setup: first unbound spawn of a type asks the user once and persists the answer, including an explicit "keep inheriting" choice.
/subagent-model command (list/set/clear) to manage bindings anytime.
- Precedence order: workspace binding > profile binding > parent inheritance.
- Sticky resume: a resumed subagent always keeps its configured model/effort; unresolvable stored aliases fail with a clear configuration error.
- Visibility: effective model/effort surfaced in the
subagent.spawned event, background task info, approval label, and tool result text.
- Tests, docs, and changeset included.
Verification
pnpm --filter @moonshot-ai/kimi-code typecheck
pnpm --filter @moonshot-ai/kimi-code test
pnpm exec oxlint --tsconfig=apps/kimi-code/tsconfig.json <changed files>
- Manual smoke test: spawn a
coder subagent with a bound cheaper model, resume it, and confirm it keeps the bound model.
Checklist
Notes for Reviewers
- This intentionally does not add a
model parameter to the Agent tool input schema; the LLM should not be able to override a user binding.
AgentSwarm is left unchanged for now; the same binding logic applies because swarms reuse the single-subagent spawn path.
摘要
子 agent 的模型和思考强度路由应由用户配置驱动,而不是由调用方 LLM 决定。本 PR 引入工作区级 [subagent.<type>] 绑定、/subagent-model 管理命令,以及粘性 resume 行为,使被 resume 的子 agent 保留其已配置的模型/effort,而不是重新对齐到父 agent 的当前模型。
相关 Issue
关闭(或关联)以下关于更细粒度子 agent 控制的请求:
动机
被委派的 Agent 子 agent 总是继承调用者当前的模型。当用户在 config.toml 中配置了多个模型别名时,他们无法把某种子 agent 类型(例如 exploration)固定到更便宜的模型,也无法把 coding 子 agent 固定到更强的模型。
PR #1841 探索的是让调用 agent 在每次调用时自行选择模型;而本 PR 采取相反方向:子 agent 的模型路由应由用户配置决定,并机械式地应用,而不是交给 LLM 决策。
采用机械式绑定而非交给 LLM 的理由:在测试中发现,agent 在 resume 时 reliably 会自己填入 model 参数,从而在用户不知情的情况下覆盖用户先前的选择。绑定机制可以完全消除这种自由裁量权。
改动内容
- 在工作区配置文件
<projectRoot>/.kimi-code/local.toml 中增加 [subagent.<type>] 绑定项(model、thinking_effort),遵循现有的 workspace.additional_dir 模式。
- 首次遇到未绑定的类型时,交互式询问用户一次,并持久化答案,包括显式的“保持继承”选择。
- 新增
/subagent-model 命令(list/set/clear),随时管理绑定。
- 优先级:工作区绑定 > profile 绑定 > 继承父 agent。
- 粘性 resume:被 resume 的子 agent 始终保留其已配置的模型/effort;无法解析的已存储别名会给出清晰的配置错误。
- 生效的模型/effort 会展示在
subagent.spawned 事件、后台任务信息、审批标签以及 tool result 文本中。
- 包含测试、文档和 changeset。
验证
pnpm --filter @moonshot-ai/kimi-code typecheck
pnpm --filter @moonshot-ai/kimi-code test
pnpm exec oxlint --tsconfig=apps/kimi-code/tsconfig.json <changed files>
- 手动冒烟测试:为
coder 子 agent 绑定一个更便宜的模型,resume 它,确认它保留绑定模型。
检查清单
给审阅者的说明
- 本 PR 故意没有给
Agent tool 的输入 schema 增加 model 参数;LLM 不应能够覆盖用户绑定。
AgentSwarm 暂时未改动;因为 swarm 复用单个子 agent 的 spawn 路径,同样的绑定逻辑自动生效。
Subagent model and thinking-effort routing should be driven by user configuration, not by the calling LLM. This PR introduces per-workspace
[subagent.<type>]bindings, a/subagent-modelmanagement command, and sticky resume behavior so that resumed subagents keep their configured model/effort instead of realigning to the parent's current model.Related Issue
Closes (or relates to) the broader request for finer-grained subagent control:
Motivation
Delegated
Agentsubagents always inherit the caller's current model. Users who configure multiple model aliases inconfig.tomlhave no way to pin a subagent type (e.g. exploration) to a cheaper model, or a coding subagent to a stronger one.PR #1841 explores letting the calling agent pick a model per call; this PR takes the opposite direction: model routing for subagents is user configuration, applied mechanically, not an LLM decision.
The rationale for keeping this mechanical rather than LLM-facing: in testing, agents reliably self-filled a
modelargument on resume, silently overriding the user's earlier choice. Bindings remove that discretion entirely.What Changed
<projectRoot>/.kimi-code/local.tomlunder[subagent.<type>](model,thinking_effort), following the existingworkspace.additional_dirpattern./subagent-modelcommand (list/set/clear) to manage bindings anytime.subagent.spawnedevent, background task info, approval label, and tool result text.Verification
pnpm --filter @moonshot-ai/kimi-code typecheckpnpm --filter @moonshot-ai/kimi-code testpnpm exec oxlint --tsconfig=apps/kimi-code/tsconfig.json <changed files>codersubagent with a bound cheaper model, resume it, and confirm it keeps the bound model.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.Notes for Reviewers
modelparameter to theAgenttool input schema; the LLM should not be able to override a user binding.AgentSwarmis left unchanged for now; the same binding logic applies because swarms reuse the single-subagent spawn path.摘要
子 agent 的模型和思考强度路由应由用户配置驱动,而不是由调用方 LLM 决定。本 PR 引入工作区级
[subagent.<type>]绑定、/subagent-model管理命令,以及粘性 resume 行为,使被 resume 的子 agent 保留其已配置的模型/effort,而不是重新对齐到父 agent 的当前模型。相关 Issue
关闭(或关联)以下关于更细粒度子 agent 控制的请求:
动机
被委派的
Agent子 agent 总是继承调用者当前的模型。当用户在config.toml中配置了多个模型别名时,他们无法把某种子 agent 类型(例如 exploration)固定到更便宜的模型,也无法把 coding 子 agent 固定到更强的模型。PR #1841 探索的是让调用 agent 在每次调用时自行选择模型;而本 PR 采取相反方向:子 agent 的模型路由应由用户配置决定,并机械式地应用,而不是交给 LLM 决策。
采用机械式绑定而非交给 LLM 的理由:在测试中发现,agent 在 resume 时 reliably 会自己填入
model参数,从而在用户不知情的情况下覆盖用户先前的选择。绑定机制可以完全消除这种自由裁量权。改动内容
<projectRoot>/.kimi-code/local.toml中增加[subagent.<type>]绑定项(model、thinking_effort),遵循现有的workspace.additional_dir模式。/subagent-model命令(list/set/clear),随时管理绑定。subagent.spawned事件、后台任务信息、审批标签以及 tool result 文本中。验证
pnpm --filter @moonshot-ai/kimi-code typecheckpnpm --filter @moonshot-ai/kimi-code testpnpm exec oxlint --tsconfig=apps/kimi-code/tsconfig.json <changed files>coder子 agent 绑定一个更便宜的模型,resume 它,确认它保留绑定模型。检查清单
gen-changesetsskill,或本 PR 不需要 changeset。gen-docsskill,或本 PR 不需要文档更新。给审阅者的说明
Agenttool 的输入 schema 增加model参数;LLM 不应能够覆盖用户绑定。AgentSwarm暂时未改动;因为 swarm 复用单个子 agent 的 spawn 路径,同样的绑定逻辑自动生效。