Repository navigation
Conversation
🦋 Changeset detectedLatest commit: b4b710e 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 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 866797a07c
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62a6afbfca
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c39c13f8d
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 200e2ff795
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfffdc6d75
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4b710e2ba
ℹ️ 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".
| await this.toolSelect.prepareCatalog(signal); | ||
| signal?.throwIfAborted(); | ||
| return this.settleInitialTools(); |
There was a problem hiding this comment.
Persist the source baseline settled by an early fork
The fresh remaining case after the earlier fork-preparation fix is a restart: when a same-profile fork is created before the source's first request, this path runs prepareCatalog(false) (so ToolSelectInitialized stays pending) and caches the completed source baseline only in settledTools, while the new child path writes inherited-tools.json. If the session is reopened before the source sends a request and the MCP catalog changed in the meantime (for example, a server was disabled), main rebuilds from the new catalog but the restored child keeps the old file, silently breaking request and prompt-cache parity. Publish or persist the source settlement here as well.
AGENTS.md reference: AGENTS.md:L131-L133
Useful? React with 👍 / 👎.
…263) The Kimi Code bridged-tools test has been failing in the nightly since Kimi Code 2.6.0. Kimi 2.6 connects to our MCP server and registers its tools, but never puts them in the tool list it sends the model. On 2.5.3 the tool shows up as before. It's a known upstream regression, MoonshotAI/kimi-code#4904: the agent loop fixes its tool list before MCP discovery finishes. A fix is in review in MoonshotAI/kimi-code#5011. The test also passed on some nights while 2.6 was out. `check_bridged_tools` only checked the name of the call the model made, and the model can guess `mcp__secrets__secret_lookup` from the prompt. Inspect's bridge then refuses the call because the tool was never offered, so the tool doesn't run, but the name check passes anyway. This PR: - adds a second assertion to `check_bridged_tools`: a `secret_lookup` `ToolEvent` with no error that returned `ALPHA-SECRET-12345`. Only a real host tool run produces that. This applies to every agent's bridged-tools test. - marks `test_kimi_code_bridged_tools` as strict xfail and links the upstream issue. The nightly goes green, keeps floating on the latest Kimi Code, and fails with XPASS once upstream fixes it. That's the cue to remove the marker. The xfail only accepts the two bridged-tool assertion messages, so a Kimi Code eval that errors or never takes a turn still fails the nightly. No migration required. Test-only change. ### Validation There are no API keys locally, so I replayed eval logs instead of calling a real model. I ran the `bridged_tools` example with `mockllm` scripted to call `mcp__secrets__secret_lookup`, then fed those logs to `check_bridged_tools` in place of `run_example`: | Log | main | this branch | |---|---|---| | Kimi 2.5.3, tool runs and returns the secret | pass | pass | | Kimi 2.6.3, model emits the right name, bridge rejects it | pass | fail (`was not proposed by the model in a bridged generation`) | Through pytest, with the replayed logs also going through `run_example`'s completion checks, the 2.6.3 log gives `XFAIL` and the 2.5.3 log gives `XPASS(strict)`, which fails. A log from an eval that errored fails outright rather than counting as the expected failure. `make check` passes. `pytest` (fast suite): 804 passed, 74 skipped, 2 failed. Neither failure touches this change: - `test_bundled_catalog_tracks_live_latest`: the live Codex catalog's latest model is now `gpt-6.2-sol`, and the bundled fallback still says `gpt-6-astra`. - `test_bundle_cached_under_pre_libc_name_when_npm_lacks_libc`: the mise npm shim recurses on my machine. ### Slow tests - Bridged tools, all five agents, against this branch's head (`24b863b`): [Inspect SWE Nightly Tests run 44390840703](https://github.com/meridianlabs-ai/actions/actions/runs/44390840703), `pytest_args=tests/test_bridged_tools.py -rA`. 5 passed, 1 xfailed, 0 failed, 0 skipped. Claude Code, Codex CLI, Gemini CLI and OpenCode pass the new assertion with real models. Kimi Code is the expected failure. - Not run: the rest of the slow suite, since this change only touches `tests/test_bridged_tools.py`. ### Agent review - Reviewer: Claude Opus via a subagent (fresh context), 1 pass. It traced the `ToolEvent` in inspect_ai's bridge source and confirmed the event is unprefixed `secret_lookup` with a plain string result for every agent, and that a call to a name the agent never offered is recorded with a permission error. - Findings: 3, all fixed. The xfail swallowed any `AssertionError`, including an errored eval, so it now matches only this test's two messages. The failure message now prints each result next to its error. The xfail's issue link was a placeholder; it now points at MoonshotAI/kimi-code#4904. - It also flagged a risk: the grant check matches tools by description, so an agent that rewrites MCP tool descriptions would now fail. The nightly run above shows none of the other four agents do. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Requirement or Bug
Resolve #4904.
用户在 MCP 服务还在启动时提交首条消息,可能在整段会话中都看不到随后发现的工具。使用
/btw或触发上下文压缩时,还可能遇到相同历史对应不同工具列表的问题,影响模型可见的工具和提示缓存前缀。Bug Reproduction Steps
配置一个需要稍晚才能完成发现的 MCP 服务,开启新会话并立即提问。比较
tool_select.initialized和首个llm.tools_snapshot中的工具名。关联 issue 提供了完整步骤和日志。要复现评审指出的分叉问题,可以关闭渐进式工具加载,让父会话先看到一个延迟加载的 MCP 工具,再断开该服务并启动
/btw。检查父子会话实际发给模型的工具定义。相关评审讨论Root Cause
创建 agent 时,Loop 提前捕获了启动工具清单。后续请求虽然会等待 MCP 发现结束,仍从早先捕获的清单构造模型请求。分叉又有自己的注册表,如果用子 agent 当前能查到的名字过滤继承清单,就会丢掉父 agent 已经捕获的定义。压缩请求也有独立的准备入口,过去会在等待 MCP 前筛选工具。
Code Changes
每个 agent 保存启动时的工具定义及注册来源。普通首轮、同配置分叉和压缩共用这份清单,最先需要它的路径等待初始发现、补入缺少的 MCP 定义并固定结果。后续请求按当前策略决定哪些延迟工具可以内联。工具来源只在引擎内部使用。
flowchart TD A["创建 agent,捕获初始定义与来源"] --> B["首次普通请求、同配置分叉或压缩"] B --> C["等待初始 MCP 目录,补入缺失定义并固定清单"] C --> D["普通请求和压缩按当前策略构造工具列表"] C --> E["同配置子 agent 继承清单"] E --> F["持有会话锁时,原子保存继承清单"] F --> G["恢复子 agent,应用当前策略和工具选择开关"] C --> H["后续发现走运行时工具目录"]packages/core/src/loop/loop-actor.ts负责首轮准备、取消和重试,沿用现有的tools.settled事件。packages/agent-core-v2/src/agent/loop/loopService.ts在调用模型前固定基线。toolSelectService.ts按来源匹配策略,并在需要内联时优先使用历史中已加载的同名定义。agentLifecycleService.ts负责复制和恢复继承清单。这样,子 agent 即使从未注册过该工具,也能复用父 agent 的定义。Behavior Changes and Affected Users
/btw/btw和同配置分叉的用户select_tools开关includeSubagents的客户端/compact的用户inherited-tools.json仅用于具有显式继承清单的子 agent,由持有会话写锁的客户端写入。主 agent 和独立绑定 profile 的 agent 继续从各自的配置恢复。客户端继续使用原有 CLI、SDK、REST、ACP 和 wire 接口。测试与验证
dfffdc6d7上运行,有 10 个用例失败。修复后全部通过,包括真实回环 HTTP MCP 的断连、运行时发现、按 ID 恢复未提问的子 agent、工具来源与策略,以及压缩时序。suggestFiles对忽略文件的断言失败,在干净的main上也能独立复现。main(1ccbe4127),OAuth 测试文件也有 7 项失败,工作区凭据刷新的同一用例独立运行也会超时。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.