Repository navigation
fix(agent-core-v2): wait for MCP discovery before tool announcements - #4364
Conversation
🦋 Changeset detectedLatest commit: d684d6d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codex Review SummaryThis 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. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a30857ac1c
ℹ️ 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".
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Requirement or Bug
修复新会话首轮遗漏动态加载的 MCP 工具公告,导致模型到第二轮才能发现这些工具的问题。
Bug Reproduction Steps
Root Cause
Reminder 在 MCP 的 before-step 等待之前生成工具公告,读到尚未完成初始化的工具注册表。公告只在新 turn 或压缩后的重新注入时计算,随后 MCP 初始化完成不会重算当前公告。
本次在生成公告前等待现有的 MCP initial-load promise,修正执行顺序;不新增初始化流程、轮询或重试。
Code Changes
在现有 tool-select 测试中增加延迟发现和等待期间取消两条回归,并添加 patch changeset。
补齐现有
toolSelectService.test.ts的 MCP 依赖注册:该单元测试使用手动组装的 strict harness,需要显式提供已经就绪的 MCP stub。此次 CI 修正只增加 4 行测试代码,不修改生产逻辑。Behavior Changes and Affected Users
动态工具加载关闭或模型不支持时,在新增等待之前返回;后续 step 的公告时机、压缩后的重算与去重保持原有规则。MCP 连接、授权、代理和工具调用路径不变。
验证:
@moonshot-ai/agent-core-v2typecheck 通过。git diff --check通过。CI 修正后的补充验证:
toolSelectService.test.ts:91 项全部通过。agent-core-v2:374 文件通过、1 文件失败;7372 项通过、1 项跳过、1 项失败。唯一失败是tool/tool.test.ts中returns the spawned agent id when a foreground subagent times out的 30 秒超时。087db850e02d3e487ac834c4867e90b3334a63d6的 Core 源码单独提取到临时目录,同一超时用例仍失败;本次不修改该基线问题,也不将本机全量结果报告为全绿。d684d6d16的远端完整 CI 已通过,五个测试分片、typecheck、lint、build 均成功;Windows job 沿用仓库既有禁用。Nix Build、pkg.pr.new 和 PR Title Checker 也已通过。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.未关联 issue;问题和复现步骤已直接写在上文。本次无新增配置或使用方式,文档无需更新。