Repository navigation
fix(teams): give ask_agent peers their bound MCP tools - #2208
Closed
codeLong1024 wants to merge 1 commit into
Closed
codeLong1024 wants to merge 1 commit into
codeLong1024 wants to merge 1 commit into
Conversation
codeLong1024
force-pushed
the
fix/peer-mcp-tools
branch
from
October 19, 2026 06:59
c92f088 to
ffdca0a
Compare
8 of 15 tasks
codeLong1024
force-pushed
the
fix/peer-mcp-tools
branch
from
October 25, 2026 23:57
ffdca0a to
12e7af8
Compare
codeLong1024
force-pushed
the
fix/peer-mcp-tools
branch
from
November 27, 2026 00:20
12e7af8 to
d0a6b53
Compare
Author
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.
Summary
Fixes #2200.
专家互调(sync
ask_agent)时,被调方拿不到自己绑定的 MCP 工具(mcp 9→0,只能回复"没有数据源")。本 PR 在 Octop 侧补上注入,不改 octop-harness,不动团队派工。改动集中在
src/octop/infra/agents/teams/team_manager.py:prepare_peer_session():非团队派工时调用新增的_attach_member_mcp()。_attach_member_mcp():default_mcp_servers();validate_mcp_servers()(共享专家 owner 的私有数据源不会越权,fail-closed);prepare_chat_mcp(connector_user_id=发起人 uid)成功后写入PeerSession.configurable["mcp_servers"];prepare抛异常会让 harness 丢掉整个PeerSession,连带 thread/session_key 一起丢)。新增
tests/unit/agents/test_team_peer_mcp.py(10 例):正常注入、未绑定跳过、加载失败全弃、部分失败全弃(all-or-nothing,与 turn/cron/IM 既有语义一致)、发起人无权的 server 被剔除、非 Octop 数字 uid 跳过、prepare 抛异常仍保留 peer session、team host 不注入、group dispatch 不注入、经to_runnable_config()后注入仍生效。Why
harness 的 MCP 工具是"默认隐藏、按请求显式开启"。现有 Dashboard / IM / cron 三条链路都会在 Octop 侧调
prepare_chat_mcp并写mcp_servers,而ask_agent(sync)走 harness one-shot 路径,没有这一步,导致被调方工具被整体过滤。修复前 —— 1:1 正常,协同为 0(Octop 1.0.2,WMS 专家 5GD96G 调 ERP 专家 8PQN88):
(同一问题在 1.0.2b7 上的表现是
tools=39->30 mcp=9->0:b7 会把 MCP 工具放进池子再被中间件滤掉,1.0.2 起 peer 路径根本不加载,计数变成0->0。根因相同,均为 peer 路径缺prepare_chat_mcp。)修复后 —— 与 1:1 一致,且能真实取数(同环境、同 prompt、fresh peer thread):
ERP 侧实际调用
ebsql-ebs_execute_query共 16 次(含 2 次 ORA 报错后自行纠正),最终:WMS 通过
ask_agent收到"去重物料数 = 15,159(按 SEGMENT1 去重,721 个库存组织)"并完成总结。(develop
64a12225与 1.0.2 在team_manager.py上无差异,以上结论适用于 develop。)语义约定
connector_user_id)processor.py:1658);留给 #1939不改什么
octop-harness的ChatRequest/build_one_shot_request签名与默认行为。mcp_use_default/ 按调用方选 MCP / 工具白名单等配置项。风险
Target branch
develop(feature / fix — default)main(release/*orhotfix/*only)Type of change
Test plan
make all→ 5039 passed;1 个与改动无关的本机环境失败(test_probe_tencent_mirror_unreachable:127.0.0.1:443被本机代理占用,改动前基线同样失败);4 个 integration 用例在 xdist 并发下偶发失败、串行复跑全过(资源型 flake,与 peer 路径无交集)uv run pytest tests/unit/agents/test_team_peer_mcp.py -q→ 10 passed(b7 与 1.0.2 两个镜像内均验证)tools=31->31 mcp=0->0→ 修复后tools=40->40 mcp=9->9,ERP 实际调用 16 次ebsql-ebs_execute_query完成真实取数(15,159)mcp=0->0,被调方回复"没有可用的 ebsql-ebs 工具"(b7 上同问题表现为mcp=9->0,本质相同)if not group才注入)Checklist
CHANGELOG.md([Unreleased] → 修复)Quick checklist(CONTRIBUTING)
team_manager.py+40/−2、新增 1 个测试文件、CHANGELOG 1 行)