Repository navigation
Conversation
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. |
🦋 Changeset detectedLatest commit: b05694c The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
commit: |
liruifengv
approved these changes
Nov 26, 2026
sailist
deleted the
bug-471-11-26-unload-declared-tools-release-11-26
branch
November 26, 2026 09:27
Merged
kimi-agent-bot
added a commit
that referenced
this pull request
Nov 26, 2026
kimi-agent-bot
added a commit
that referenced
this pull request
Nov 26, 2026
6 tasks done
sailist
pushed a commit
that referenced
this pull request
Nov 26, 2026
* chore(changeset): add product notes for #5515 and clarify #5516 * ci: release packages (#5519) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: kimi-agent-bot <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
11 tasks
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Dec 2, 2026
The upstream ledger reads `upstream/main ^main`, so a commit that only ever existed on a `@moonshot-ai/kimi-code@<version>` release branch was never enumerated: 89 commits reachable from 2.6.0-2.8.1 are absent from upstream/main, 20 of them are owned by an existing main-ledger row (by sha or PR), and the other 69 had no row anywhere and no path into the ledger at all. `.upstream/release-ledger.tsv` now carries one row per release-only commit the main ledger does not own, in the main ledger's 11 columns plus a `tags` column recording every version that reaches the commit. `scripts/upstream-ledger.mjs` gains two entries that share `scripts/lib/upstream-ledger-probes.mjs` with the existing tooling: - `--release-refresh` fetches upstream main, enumerates the tag union, refreshes each row's tag list, and adds a pending row for every commit neither ledger owns. Rows whose commit is no longer release-only are reported, never deleted. - `--release-verify` fails by name when a release tag commit has no row in either ledger, runs each release row's probe with the same runner-aware skip semantics as the main verify, holds `ported` rows to the shared per-commit file-completeness check, and re-runs the live probes of release commits the main ledger owns, so MoonshotAI#4875/MoonshotAI#4905/MoonshotAI#4922 stay on their probes instead of getting duplicate rows. The initial classification is evidence-based: 15 release-metadata commits are not-applicable with a written reason, 1 is ported (its patch reverse-applies), 16 are equivalent with live grep/test probes, 13 are partial with the present and absent halves named, and 24 are pending with file and added-line evidence. M39's "confirmed absent" list was partly stale: MoonshotAI#4995's Stop-hook code is in the tree, MoonshotAI#5354's one-line change is fully present, MoonshotAI#5516 is the twin of the ported MoonshotAI#5438, and MoonshotAI#5096/MoonshotAI#5191/MoonshotAI#5303 are present at source level, so those rows carry the evidence that says so rather than an absence claim. Verified: release verify -> 44 probes pass, 0 skipped, 0 fail, completeness 1/1, 0 missing rows, 0 hidden failures; main ledger verify -> 317 probes pass, 2 skipped, 0 fail, 332/332 closed rows complete; upstream-ledger-release fixture test 16 pass; upstream-ledger-probes 29 pass; bun run lint 0 warnings 0 errors and ratchet green on 6995 files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirement or Bug
将已合入
main的 #5438(原始提交44136f6a/ squash523bc8f7)零冲突移植到release/2026-11-26,随 11-26 版本发布。使用支持动态工具加载(
dynamically_loaded_tools)的 Kimi 模型时,如果某个工具只在<tools_added>目录公告里出现过名字、从未通过select_tools向模型声明过 schema,之后该工具从注册表消失(例如宿主在创建会话后收窄内置工具名单再重启恢复、未加载的 deferred MCP 被停用/删除、或/tower off),Core 仍会在请求里发送unload_tools。严格校验的网关会拒绝“卸载未声明工具”,导致恢复后的会话无法继续对话。本 PR 让unload_tools只与请求内此前同名的systemschema 声明消息配对,旧会话无需迁移即可恢复。Bug Reproduction Steps
dynamically_loaded_tools的 Kimi 协议模型,并注册一个 deferred MCP 服务(或先全量注册内置工具、再通过策略禁用后重启恢复会话)。<tools_added>中看到工具名,不调用select_tools加载其 schema。{ "role": "system", "unload_tools": ["<从未声明的工具名>"] }。Root Cause
根因是把“注册表/可加载目录变化”直接等同于“模型侧 schema 卸载”:
AgentToolSelectService.reconcile()对比持久化账本与实时toolRegistry.list(),把消失的工具记入removed;renderDeltaAnnouncement()不区分这些工具是否曾注入system.tools,全部写入tool_lifecyclemeta 的removed。shapeActiveHistory()虽然已经在按顺序维护declaredDynamicTools(本次请求里实际保留的system.tools声明),但只用它做同名 schema 去重,没有过滤公告上的meta.removed。kimiOpenAIProtocol.message()看到非空meta.removed就无条件追加unload_tools,而后端按单次无状态请求判断工具是否声明过。这是对“卸载声明生成规则”的根本修复(不针对特定工具加名单);宿主分步创建会话导致的注册表与账本不一致不在本 PR 重做。
Code Changes
以
release/2026-11-26基线(46d9085f,即 11-25 发版提交,已含 #5369 带入的 Tower deferred tools)移植44136f6a,无冲突,patch-id 与 #5438 完全一致。只改请求出站视图整形的一处边界,不改 loop 持久化历史、不改
reconcile()的目录公告逻辑,下游 Kimi 协议层与legalize-tools无需改动:shapeActiveHistory(messages, tools) for message of messages if isLoadableToolsAnnouncement(message) - delete meta.removed names from declaredDynamicTools + keep only names deleted from declaredDynamicTools in outbound meta.removed next = shapeActiveMessage(message, inlineNames, declaredDynamicTools)system.tools(自动排除当前请求顶层inlineNames),而不是<tools_added>。<tools_removed>公告之后,保证已加载工具同名更新的旧 system.tools→unload_tools→新 system.tools时序,并避免改动历史前缀破坏缓存。<tools_removed>正文保持不变,模型仍能得知哪些名字不再可select_tools;未发生过滤的消息保持原引用,落盘历史完全不改写。@moonshot-ai/agent-core-v2、@moonshot-ai/kimi-code、kimi-code-app);fix(agent-core-v2): unload only previously declared dynamic tools #5438 未进入 11-25 发版,release 分支上无重复条目。阅读顺序:先看
packages/agent-core-v2/src/agent/toolSelect/toolSelectService.ts的shapeActiveHistory/shapeLifecycleAnnouncement,再看packages/agent-core-v2/test/agent/toolSelect/toolSelectService.test.ts的恢复与未加载更新回归用例;docs/en/llm.md与 changeset 可略读。Behavior Changes and Affected Users
removed)unload_toolsmeta.removed剔除,不发unload_tools;<tools_removed>正文与落盘历史保留unload_toolssystem.tools声明profile.tools声明的 inline 工具出现在历史removed中unload_toolssystem.tools加载的 MCP / deferred 工具被移除或同名 schema 更新unload_tools,同名更新按“旧定义 → unload → 新定义”发送unload_toolsdynamically_loaded_tools的模型及其他 provider受影响模块与测试覆盖:
packages/agent-core-v2/src/agent/toolSelect/toolSelectService.ts:新增出站公告的removed过滤。packages/agent-core-v2/test/agent/toolSelect/toolSelectService.test.ts:新增恢复会话只卸载已声明system.tools工具的回归用例,并补强未加载同名更新不产出unload_tools的断言(原 PR fix(agent-core-v2): unload only previously declared dynamic tools #5438 修复前两条均失败,修复后通过)。unload_tools的协议校验属于独立配套项);Windows 专项(Windows 远程环境连接失败;不涉及平台路径/进程行为)。验证记录
tsc -p packages/agent-core-v2/tsconfig.json --noEmit与tsc -p packages/core/tsconfig.json --noEmit:通过。vitest run packages/agent-core-v2/test/agent/toolSelect packages/agent-core-v2/test/agent/loop/coreLoopService.test.ts packages/agent-core-v2/test/session/subagent/forkParity.test.ts:5 文件 162/162 通过。vitest run packages/core/test(@moonshot-ai/core全量):36 文件 398/398 通过。46d9085f):pnpm lint(含 check-comments、type-aware oxlint--deny-warnings、import-boundaries、guards、ratchet、instructions 等)0 warning / 0 error;pnpm run check:duplication通过。Checklist
main的 fix(agent-core-v2): unload only previously declared dynamic tools #5438).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.