fix(team): stabilize MCP injection pipeline and unify backend whitelists#2152
fix(team): stabilize MCP injection pipeline and unify backend whitelists#2152
Conversation
…ts from team creation
- Add ipcBridge import to AcpAgent for MCP status events - Add team IPC bridge import to TeamMcpServer Full changes in progress: Codex session/load fix, IPC status events, whitelist expansion (codebuddy/gemini), TCP error logging.
- Fix Codex session/load hardcoded mcpServers: [] (tools lost on resume) - Add TeamMcpPhase/ITeamMcpStatusEvent types for injection observability - Add team.mcpStatus IPC channel for frontend status tracking - Emit IPC events: tcp_ready/tcp_error, session_injecting/session_ready/degraded/session_error, load_failed - Expand TEAM_ALLOWED_BACKENDS: add codebuddy, gemini - Expand MCP_CAPABLE_TYPES: add gemini - Add codebuddy to frontend TEAM_SUPPORTED_BACKENDS - Add TCP error stderr logging in team-mcp-stdio bridge - Add conversation.extra write failure IPC event
…auth expiry When WebSocket receives auth-expired or 1008 close code, the redirect to login page used window.location.href = '/login' which triggers a full page reload. With HashRouter, the reload lands on an empty hash (#/) and the WebSocket is still disconnected, so status stays 'checking' forever → blank screen. Fix: use window.location.hash = '/login' to navigate within the SPA without reloading the page.
- Add team-mcp-stdio bridge as a self-contained ESM bundle for better integration. - Introduce new Playwright test commands for team-related end-to-end testing. - Update TEAM_SUPPORTED_BACKENDS to include 'gemini' and remove 'codebuddy'. - Refactor MCP server handling to ensure team mode agents are properly validated and injected. - Improve error handling and logging for MCP server initialization and agent communication. - Update XML fallback instructions to always provide a coordination path for agents.
Add a dev-only Vite plugin that runs build-mcp-servers.js after each main process bundle, so team-mcp-stdio.js is always available without a manual build step.
- Remove index.html (Vite build artifact, should not be committed) - Remove docs/research/ (investigation notes, not production code)
…ion logic - Choose stash version (options object style) for loadSession signature - Use doSession inner function pattern for cleaner error handling - Retain teamId bypass for busy check in AcpSendBox and GeminiSendBox
Restore 9 test files that were deleted and 6 that had cases trimmed, bringing tests back to parity with the main branch.
These research documents pre-exist on main and were mistakenly removed in 0921063. Only branch-specific research docs should have been deleted.
loadSession now receives mcpServers as a direct array parameter instead of wrapped in an object. Update test expectations accordingly.
…n-stability # Conflicts: # src/common/types/teamTypes.ts # src/process/team/TeammateManager.ts # tests/integration/team-real-components.test.ts
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Code Review:fix(team): stabilize MCP injection pipeline for all agent backends (#2152)变更概述本 PR 修复了 Codex 方案评估结论:✅ 方案合理 核心修复(Codex 问题清单🟡 MEDIUM — electron-builder.yml 中
|
| # | 严重级别 | 文件 | 问题 |
|---|---|---|---|
| 1 | 🟡 MEDIUM | electron-builder.yml:117 |
extraResources 引用不存在的 .mjs 文件 |
| 2 | 🔵 LOW | TeamMcpServer.ts:14 |
未使用的导入 teamIpcBridge |
| 3 | 🔵 LOW | xmlFallbackAdapter.ts:126 |
options 参数已无效,未清理 |
| 4 | 🔵 LOW | TeamSessionService.ts |
新增核心逻辑 patch 覆盖率 0% |
结论
electron-builder.yml 无效条目),以及若干 LOW 级清理项,处理后可合并。
本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。
CONCLUSION: CONDITIONAL
IS_CRITICAL_PATH: true
CRITICAL_PATH_FILES:
- electron-builder.yml
- package.json
PR_NUMBER: 2152
The entry referenced out/main/team-mcp-stdio.mjs which does not exist; the build script outputs team-mcp-stdio.js (CJS). Runtime resolution already works via the existing asarUnpack entry for the .js file. Review follow-up for #2152
PR Fix 验证报告原始 PR: #2152 修复结果
总结: ✅ 已修复 1 个 | ⏭️ 跳过 3 个(LOW 级别)
|
|
✅ 已自动修复,代码无阻塞性问题,请人工确认后合并。 |
…defaults Merge latest main (including #2278 team-guide) and resolve conflicts in ipcBridge.ts and teamTypes.ts, retaining both team-guide IPC channels (setSessionMode, listChanged) and MCP stability IPC (mcpStatus). Fix agent type handling discovered during review: - AionMcpService.handleCreateTeam now accepts agentType from caller and validates against TEAM_GUIDE_BACKENDS whitelist instead of hardcoding claude - team_spawn_agent tool description updated to reference the dynamic "Available Agent Types" list instead of a stale hardcoded list - Leader prompt now guides agent to pass agent_type when spawning - spawnAgent fallback defaults to leader's own type instead of claude
…/iOfficeAI/AionUi into fix/team-mcp-injection-stability
The team guide prompt example table showed "claude" for all role types, causing LLMs (including codex/GPT agents) to copy it verbatim instead of using their own backend type. Replace with "(your type)" placeholder and explicit instruction to use the agent's own type.
Pass the agent's backend (e.g. 'codex') into getTeamGuidePrompt() so the example team configuration table shows the correct type instead of a placeholder. This prevents LLMs from copying a hardcoded 'claude' when they should use their own backend type.
…stem env - Eliminate TEAM_GUIDE_BACKENDS; use TEAM_SUPPORTED_BACKENDS as single source of truth for both team mode and solo-to-team guide injection - Add gemini to team guide whitelist (was previously excluded) - Inject AION_MCP_BACKEND env var into stdio bridge so the system automatically passes the correct agent type to aion_create_team, removing dependency on LLM to specify agentType parameter - Add aion team-guide MCP server injection for GeminiAgentManager solo mode - Update tests: gemini now whitelisted, backend via system env not args
…sts (#2152) * fix(team): remove CodeBuddy references and filter out custom assistants from team creation * fix(team): stabilize MCP injection pipeline [WIP] - Add ipcBridge import to AcpAgent for MCP status events - Add team IPC bridge import to TeamMcpServer Full changes in progress: Codex session/load fix, IPC status events, whitelist expansion (codebuddy/gemini), TCP error logging. * fix(team): stabilize MCP injection pipeline with status events - Fix Codex session/load hardcoded mcpServers: [] (tools lost on resume) - Add TeamMcpPhase/ITeamMcpStatusEvent types for injection observability - Add team.mcpStatus IPC channel for frontend status tracking - Emit IPC events: tcp_ready/tcp_error, session_injecting/session_ready/degraded/session_error, load_failed - Expand TEAM_ALLOWED_BACKENDS: add codebuddy, gemini - Expand MCP_CAPABLE_TYPES: add gemini - Add codebuddy to frontend TEAM_SUPPORTED_BACKENDS - Add TCP error stderr logging in team-mcp-stdio bridge - Add conversation.extra write failure IPC event * fix(team): stabilize MCP injection pipeline with IPC status events * fix(webui): use hash navigation to prevent blank screen on WebSocket auth expiry When WebSocket receives auth-expired or 1008 close code, the redirect to login page used window.location.href = '/login' which triggers a full page reload. With HashRouter, the reload lands on an empty hash (#/) and the WebSocket is still disconnected, so status stays 'checking' forever → blank screen. Fix: use window.location.hash = '/login' to navigate within the SPA without reloading the page. * feat(team): enhance MCP server integration and testing capabilities - Add team-mcp-stdio bridge as a self-contained ESM bundle for better integration. - Introduce new Playwright test commands for team-related end-to-end testing. - Update TEAM_SUPPORTED_BACKENDS to include 'gemini' and remove 'codebuddy'. - Refactor MCP server handling to ensure team mode agents are properly validated and injected. - Improve error handling and logging for MCP server initialization and agent communication. - Update XML fallback instructions to always provide a coordination path for agents. * fix(dev): auto-build MCP server bundles in dev mode Add a dev-only Vite plugin that runs build-mcp-servers.js after each main process bundle, so team-mcp-stdio.js is always available without a manual build step. * chore: remove build artifact and research docs from PR - Remove index.html (Vite build artifact, should not be committed) - Remove docs/research/ (investigation notes, not production code) * fix(team): resolve merge conflicts in AcpConnection and AcpAgent session logic - Choose stash version (options object style) for loadSession signature - Use doSession inner function pattern for cleaner error handling - Retain teamId bypass for busy check in AcpSendBox and GeminiSendBox * test: restore deleted/trimmed unit tests from main Restore 9 test files that were deleted and 6 that had cases trimmed, bringing tests back to parity with the main branch. * fix(acp): use direct mcpServers param in loadSession, align caller in index.ts * fix(gemini): restore stripCodeExecutionBlocks function lost during merge * fix: restore docs/research files that exist on main These research documents pre-exist on main and were mistakenly removed in 0921063. Only branch-specific research docs should have been deleted. * test(team): update MCP_CAPABLE_TYPES assertion to reflect gemini support * test(acp): align loadSession assertions with direct mcpServers param loadSession now receives mcpServers as a direct array parameter instead of wrapped in an object. Update test expectations accordingly. * test(integration): add mcpStatus mock to team-real-components ipcBridge * test(team): update tests to reflect gemini support and always-on XML fallback * style: auto-format files to pass oxfmt CI check * fix(build): remove invalid team-mcp-stdio.mjs extraResources entry The entry referenced out/main/team-mcp-stdio.mjs which does not exist; the build script outputs team-mcp-stdio.js (CJS). Runtime resolution already works via the existing asarUnpack entry for the .js file. Review follow-up for #2152 * fix(team-guide): replace hardcoded claude in prompt example table The team guide prompt example table showed "claude" for all role types, causing LLMs (including codex/GPT agents) to copy it verbatim instead of using their own backend type. Replace with "(your type)" placeholder and explicit instruction to use the agent's own type. * fix(team-guide): inject actual backend type into prompt example table Pass the agent's backend (e.g. 'codex') into getTeamGuidePrompt() so the example team configuration table shows the correct type instead of a placeholder. This prevents LLMs from copying a hardcoded 'claude' when they should use their own backend type. * fix(team-guide): unify backend whitelist and inject agent type via system env - Eliminate TEAM_GUIDE_BACKENDS; use TEAM_SUPPORTED_BACKENDS as single source of truth for both team mode and solo-to-team guide injection - Add gemini to team guide whitelist (was previously excluded) - Inject AION_MCP_BACKEND env var into stdio bridge so the system automatically passes the correct agent type to aion_create_team, removing dependency on LLM to specify agentType parameter - Add aion team-guide MCP server injection for GeminiAgentManager solo mode - Update tests: gemini now whitelisted, backend via system env not args * fix(team-guide): prevent Gemini from using ask_user tool for team confirmation * fix(team-guide): inject team guide prompt into Gemini solo agents * fix(team-guide): use dynamic conversationType for team leader based on backend --------- Co-authored-by: zhuqingyu <zhuqingyu@bituniverse.org> Co-authored-by: zynx <>
…sts (iOfficeAI#2152) * fix(team): remove CodeBuddy references and filter out custom assistants from team creation * fix(team): stabilize MCP injection pipeline [WIP] - Add ipcBridge import to AcpAgent for MCP status events - Add team IPC bridge import to TeamMcpServer Full changes in progress: Codex session/load fix, IPC status events, whitelist expansion (codebuddy/gemini), TCP error logging. * fix(team): stabilize MCP injection pipeline with status events - Fix Codex session/load hardcoded mcpServers: [] (tools lost on resume) - Add TeamMcpPhase/ITeamMcpStatusEvent types for injection observability - Add team.mcpStatus IPC channel for frontend status tracking - Emit IPC events: tcp_ready/tcp_error, session_injecting/session_ready/degraded/session_error, load_failed - Expand TEAM_ALLOWED_BACKENDS: add codebuddy, gemini - Expand MCP_CAPABLE_TYPES: add gemini - Add codebuddy to frontend TEAM_SUPPORTED_BACKENDS - Add TCP error stderr logging in team-mcp-stdio bridge - Add conversation.extra write failure IPC event * fix(team): stabilize MCP injection pipeline with IPC status events * fix(webui): use hash navigation to prevent blank screen on WebSocket auth expiry When WebSocket receives auth-expired or 1008 close code, the redirect to login page used window.location.href = '/login' which triggers a full page reload. With HashRouter, the reload lands on an empty hash (#/) and the WebSocket is still disconnected, so status stays 'checking' forever → blank screen. Fix: use window.location.hash = '/login' to navigate within the SPA without reloading the page. * feat(team): enhance MCP server integration and testing capabilities - Add team-mcp-stdio bridge as a self-contained ESM bundle for better integration. - Introduce new Playwright test commands for team-related end-to-end testing. - Update TEAM_SUPPORTED_BACKENDS to include 'gemini' and remove 'codebuddy'. - Refactor MCP server handling to ensure team mode agents are properly validated and injected. - Improve error handling and logging for MCP server initialization and agent communication. - Update XML fallback instructions to always provide a coordination path for agents. * fix(dev): auto-build MCP server bundles in dev mode Add a dev-only Vite plugin that runs build-mcp-servers.js after each main process bundle, so team-mcp-stdio.js is always available without a manual build step. * chore: remove build artifact and research docs from PR - Remove index.html (Vite build artifact, should not be committed) - Remove docs/research/ (investigation notes, not production code) * fix(team): resolve merge conflicts in AcpConnection and AcpAgent session logic - Choose stash version (options object style) for loadSession signature - Use doSession inner function pattern for cleaner error handling - Retain teamId bypass for busy check in AcpSendBox and GeminiSendBox * test: restore deleted/trimmed unit tests from main Restore 9 test files that were deleted and 6 that had cases trimmed, bringing tests back to parity with the main branch. * fix(acp): use direct mcpServers param in loadSession, align caller in index.ts * fix(gemini): restore stripCodeExecutionBlocks function lost during merge * fix: restore docs/research files that exist on main These research documents pre-exist on main and were mistakenly removed in 0921063. Only branch-specific research docs should have been deleted. * test(team): update MCP_CAPABLE_TYPES assertion to reflect gemini support * test(acp): align loadSession assertions with direct mcpServers param loadSession now receives mcpServers as a direct array parameter instead of wrapped in an object. Update test expectations accordingly. * test(integration): add mcpStatus mock to team-real-components ipcBridge * test(team): update tests to reflect gemini support and always-on XML fallback * style: auto-format files to pass oxfmt CI check * fix(build): remove invalid team-mcp-stdio.mjs extraResources entry The entry referenced out/main/team-mcp-stdio.mjs which does not exist; the build script outputs team-mcp-stdio.js (CJS). Runtime resolution already works via the existing asarUnpack entry for the .js file. Review follow-up for iOfficeAI#2152 * fix(team-guide): replace hardcoded claude in prompt example table The team guide prompt example table showed "claude" for all role types, causing LLMs (including codex/GPT agents) to copy it verbatim instead of using their own backend type. Replace with "(your type)" placeholder and explicit instruction to use the agent's own type. * fix(team-guide): inject actual backend type into prompt example table Pass the agent's backend (e.g. 'codex') into getTeamGuidePrompt() so the example team configuration table shows the correct type instead of a placeholder. This prevents LLMs from copying a hardcoded 'claude' when they should use their own backend type. * fix(team-guide): unify backend whitelist and inject agent type via system env - Eliminate TEAM_GUIDE_BACKENDS; use TEAM_SUPPORTED_BACKENDS as single source of truth for both team mode and solo-to-team guide injection - Add gemini to team guide whitelist (was previously excluded) - Inject AION_MCP_BACKEND env var into stdio bridge so the system automatically passes the correct agent type to aion_create_team, removing dependency on LLM to specify agentType parameter - Add aion team-guide MCP server injection for GeminiAgentManager solo mode - Update tests: gemini now whitelisted, backend via system env not args * fix(team-guide): prevent Gemini from using ask_user tool for team confirmation * fix(team-guide): inject team guide prompt into Gemini solo agents * fix(team-guide): use dynamic conversationType for team leader based on backend --------- Co-authored-by: zhuqingyu <zhuqingyu@bituniverse.org> Co-authored-by: zynx <>
Summary
Stabilizes the team MCP injection pipeline and unifies the solo-to-team flow across all three backends (Claude, Gemini, Codex).
MCP Injection Pipeline Stability
mcpStatusevents to track TCP server → session injection → load lifecycle phasesloadSessionto passmcpServersdirectly instead of relying on stale config statebuild-mcp-servers.jsruns on main process rebuild)Backend Whitelist Unification
TEAM_SUPPORTED_BACKENDS(Set(['claude', 'codex', 'gemini'])) inteamTypes.tsas the single source of truthTEAM_GUIDE_BACKENDS— all references now useTEAM_SUPPORTED_BACKENDSExtend Solo-to-Team to Gemini & Codex (Claude already supported)
AION_MCP_BACKENDenv var injected into stdio bridge at spawn time — replaces LLM-dependentagentTypeparameter for all backendsgetTeamGuidePrompt('gemini')intoGeminiAgentManager.createBootstrap()so Gemini knows when/how to recommend teamsAionMcpService.handleCreateTeamnow usesgetConversationTypeForBackend(agentType)instead of hardcoded'acp'— fixes Gemini leader crash (red status) after team creationagentTypefrom MCP tool schema: the system injects backend type via env var, removing LLM's ability to pass wrong typeTeam Mode Enhancements
sessionModetoTTeamfor persisting permission mode across agent spawnsITeamListChangedEventIPC event for frontend team list refreshTesting
teamGuideWhitelist.test.ts,aionMcpServer.test.ts(backend injection),teamMcpServerEvents.test.tsAcpAgentManagerSkillInjection.test.ts(Gemini now expects team guide injection)Test plan
conversationType(gemini→gemini, claude→acp)aion_create_team: agent callsaion_navigateto redirect useraion-mcp-stdio.jsunpacked from asar, AION_MCP_BACKEND read at runtime