Repository navigation
feat: remove experimental subagent context forking - #5254
Conversation
🦋 Changeset detectedLatest commit: de97dcd The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
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 |
25d5b2a to
e110723
Compare
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e1107238b5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| surface: 'core', | ||
| }; | ||
|
|
||
| registerFlagDefinition(subagentForkFlag); |
There was a problem hiding this comment.
Reject stale subagent_fork configuration
When an upgrade leaves [experimental].subagent_fork = true in config.toml, removing this registration does not make the setting invalid: ExperimentalConfigSchema still accepts any boolean key and FlagService only evaluates registered definitions, so startup succeeds, /meta drops the flag, and the user's explicit setting has no effect. Add retired-key validation with a clear removal error instead of silently accepting this configuration.
AGENTS.md reference: AGENTS.md:L118-L118
Useful? React with 👍 / 👎.
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "@moonshot-ai/agent-core-v2": patch | |||
There was a problem hiding this comment.
Standalone @moonshot-ai/kimi-code-sdk consumers receive the removed tool schemas too, because packages/node-sdk/tsdown.config.ts bundles every @moonshot-ai/* dependency and this commit updates SDK integration tests for the new core behavior. None of the new changesets names the SDK, so its next build can ship this user-visible removal under only unrelated pending release notes; add an SDK changeset that describes the lost experimental parameter.
AGENTS.md reference: AGENTS.md:L169-L170
Useful? React with 👍 / 👎.
e110723 to
de97dcd
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de97dcde45
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "@moonshot-ai/agent-core-v2": patch | |||
There was a problem hiding this comment.
Add the migration-legacy changeset
This diff changes packages/migration-legacy/src/steps/config.ts so legacy migrations no longer register or preserve subagent_fork, but none of the new changesets names @moonshot-ai/migration-legacy. That leaves this changed library without the required version/changelog entry; add a technical changeset for that package.
AGENTS.md reference: AGENTS.md:L169-L170
Useful? React with 👍 / 👎.
| .refine((flags) => !('subagent_fork' in flags), { | ||
| path: ['subagent_fork'], | ||
| message: | ||
| 'The experimental flag "subagent_fork" was removed. Remove it from [experimental] in config.toml.', |
There was a problem hiding this comment.
Align the SDK validator with the retired flag rule
For SDK consumers that call the exported createKimiConfigRpc().validateConfigToml (or loadRuntimeConfigSafe), this refinement exists only in the core registry: packages/node-sdk/src/config/schema.ts still accepts every boolean experimental key, and config-rpc.ts validates through that schema. Consequently [experimental].subagent_fork = true is reported valid by the SDK even though engine startup and config writes now reject it here; update the SDK schema and its validator tests as well.
AGENTS.md reference: AGENTS.md:L118-L118
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0992d81560
ℹ️ 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".
| requested ?? (fork ? (own.profileName ?? DEFAULT_PROFILE_NAME) : DEFAULT_PROFILE_NAME); | ||
| input.profileName !== undefined && input.profileName.length > 0 | ||
| ? input.profileName | ||
| : DEFAULT_PROFILE_NAME; |
There was a problem hiding this comment.
Preserve an escape hatch for opted-in context forks
For users who opted into context forking, this now defaults an omitted subagent_type to coder, and the spawn path always creates a fresh agent, so there is no way to retain the old behavior. The changeset records the loss, but the diff provides neither an escape hatch nor a test preserving that behavior; the repository requires a test and either an escape hatch or explicit maintainer sign-off before deleting it.
AGENTS.md reference: AGENTS.md:L195-L197
Useful? React with 👍 / 👎.
commit: |
Remove the experimental `fork` parameter from the Agent and AgentSwarm tools (MoonshotAI#5254): the subagent_fork flag and its /experiments entry, the schema parameters and flag-gated parameter sets, the lifecycle fork spawn path and its reminder notice, the `fork` plan field, the subagent_created telemetry field, the fork-only backend compatibility rule, and the pending changeset that announced the feature. Docs drop the env var and the parameter text in both locales; six changesets describe the removal for the CLI, engine, desktop, migration, SDK and VS Code packages. Fork adaptations: the external-backend parameter, the subagent depth labels and the fork's DI shapes stay. The unrelated model-with-resume-only rejection that the merge resolution had carried from the still-pending MoonshotAI#5190 is dropped, so the fork keeps ignoring `model` when resuming without items. The port also fixes two defects in that resolution which the tests exposed: planSpawn reads the caller profile through IAgentProfileService, and spawn passes the computed labels so the subagentDepth label survives. Verified: agent-core-v2 affected files 285 pass / 2 fail, both failures pre-existing at 2fa1821 (tool.test registered-user-tools wire snapshot, forkParity TaskStop timeout); swarm 32, sessionSwarm 50, spawn 22, experiments 13, node-sdk flags 1, node-sdk prompt events 18, kap-server meta 10; typecheck clean for agent-core-v2, kap-server, node-sdk and kimi-code; check:no-comments and the locale gates green.
The MoonshotAI#5254 row carried the counts from the interrupted first pass: 285 pass / 2 fail with both called pre-existing. Re-running the six-file set through the package's own 30s timeout gives 286 pass / 1 fail, and the forkParity TaskStop case passes in 10.4s, so only the tool.test registered-user-tools snapshot is red and its block and producers are unchanged since a512a85. Record the measured figures and drop the per-file counts the first pass did not measure.
Requirement or Bug
维护者决定下线实验性的 subagent context forking 能力。此前显式启用
subagent_fork的用户可以让Agent/AgentSwarm创建的 subagent 继承调用方对话快照;这会额外维护一条与普通 subagent 创建完全不同的生命周期、工具继承和提示词路径。本 PR 删除该实验开关及专属运行时分支,让所有新 subagent 统一走现有的 profile/model 校验、环境 lease 和
agentLifecycle.create路径;通用会话/fork、BTW 和底层 agent lifecycle fork 保持可用。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
核心思路是删除公开参数和分支,而不是把实验开关默认值翻转后继续保留不可达实现。删除后,新 subagent 只有一条创建路径:
具体变化:
Agent和AgentSwarm的输入 schema 中删除fork,并增加契约断言,防止该参数重新出现。subagent_forkflag、对应环境变量、实验功能列表注册、legacy config migration 注册和两段 fork 工具指导。[experimental].subagent_fork与其他未注册实验 ID 一样沿用原有容忍行为,不增加退役 key 专用校验。resume/subagent_type/model的兼容校验,以及 fork 专属 reminder。SubagentSpawnPlan、AgentRunSpawnedMeta和subagent_created遥测中删除fork字段。forkedFrommetadata、通用 lifecycle fork、BTW 和/fork会话路径;本 PR 没有修改 wire/state manifest 或历史会话格式。阅读顺序:
packages/agent-core-v2/src/agent/tools/agent/agent.ts与agentTool.ts:确认Agent契约和执行分支。packages/agent-core-v2/src/features/swarm/tools/agent-swarm/:确认 swarm 参数与批量 spawn plan。packages/agent-core-v2/src/session/subagent/spawn.ts与subagentService.ts:确认最终只剩普通创建路径。packages/agent-core-v2/src/app/telemetry/events.ts、docs/{en,zh}/configuration/env-vars.md:确认遥测和公开配置同步。其余改动主要是专属测试删除、普通测试夹具收敛、changeset 和 test-double 基线下降。
Behavior Changes and Affected Users
Agent输入subagent_fork后可传fork: truefork,带该参数的调用会被工具参数校验拒绝AgentSwarm输入fork,批量调用只能创建普通 subagentprompt_templateAgent工具指导fork: true继承当前类型、模型和工具集AgentSwarm工具指导fork: true让每个 item subagent 继承调用方历史prompt_template中显式提供共享上下文KIMI_CODE_EXPERIMENTAL_SUBAGENT_FORK、[experimental].subagent_fork或总开关可启用功能[experimental].subagent_fork与其他未注册实验 ID 一样被忽略,同 section 的其他有效 flag 保持生效subagent_type/modelsubagent_created遥测forksubagent_fork~/.kimi/迁移且配置了该 flag 的用户forkedFrommetadata、wire 数据、BTW、/fork和 lifecycle fork 可用Agent/AgentSwarm新建 context-fork subagent/fork用户受影响模块与覆盖:
Agent/AgentSwarmschema:两条断言固定fork不再出现。/meta与 SDK telemetry 测试改用仍存在的实验 flag;继续由现有测试固定未注册实验 ID 的容忍行为。验证记录
通过:
pnpm lintpnpm exec tsc -p packages/agent-core-v2/tsconfig.json --noEmitpnpm exec tsc -p packages/node-sdk/tsconfig.json --noEmitpnpm exec tsc -p apps/kimi-code/tsconfig.json --noEmitpnpm exec tsc -p packages/migration-legacy/tsconfig.json --noEmittool.test.ts -t 'removed':7 tests passed/meta:36 tests passedpnpm -C docs run buildpnpm changeset statuspnpm run check:duplication 634db7a7a9d656cf72289a012b59bca6edb963c2基线失败核对:
sdk-rpc-client-v2.test.ts的serves suggestFiles through the workspace handler fs service:默认建议包含ignored-app.ts。634db7a7a9独立 worktree 中单独运行同一用例,得到相同断言失败;本 PR 没有修改文件建议逻辑或该用例。Changeset:
@moonshot-ai/agent-core-v2: patch@moonshot-ai/migration-legacy: patch@moonshot-ai/kimi-code-sdk: minor@moonshot-ai/kimi-code: minorkimi-code-app: minorkimi-code: minorChecklist
/approve).(无 issue;本 PR 实现维护者直接提出的实验功能下线要求。)gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.