fix: sandbox_docker_mcp 降为可选 extra 修复默认启动崩溃 - #8
Merged
Conversation
sandbox_docker_mcp 只有 pion mcp 子进程需要,却被声明为核心依赖并在 包导入时无条件 import,导致缺包时默认 --sandbox off 也直接崩溃。 将其降为可选 extra,主进程不再 import;Docker 预检下推到子进程, MCP 启动失败则 fail-fast。
test_mcp_server.py 启动 pion mcp 子进程做端到端测试,子进程运行 sandbox_docker_mcp 的 server 循环(PION_SANDBOX_BACKEND=off 也一样)。 extra 未安装的 CI 环境里子进程会退出、连接关闭导致整组失败,与 test_sandbox_adapter.py 一致改为整文件 importorskip。
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.
问题
Docker sandbox 已抽成独立的
sandbox-docker-mcpMCP server,只有pion mcp子进程需要它。但它被声明为核心依赖,并在包导入时被无条件 import(sandbox/__init__.py→docker.py),导致缺包时默认--sandbox off也直接ModuleNotFoundError崩溃。改动(2 个原子提交)
fix:降级为可选 extra + 主进程解耦pyproject.toml:git 依赖从核心dependencies移到[project.optional-dependencies].sandbox;dev 组不含它,让 CI 默认在"缺包"环境跑,作为解耦回归门。pion/sandbox/__init__.py:不再 import.docker,__all__移除两个名字。pion/cli/__init__.py:只导入build_runtime。pion/cli/bootstrap.py:移除主进程内 Docker 预检;改为 MCP 启动后 fail-fast——mcp 后端下 sandbox server(唯一工具来源)没连上就报错并Exit(1)。pion/mcp/client.py:新增MCPClientManager.connected_server_names。pion/mcp/sandbox_server.py:外部 import 下沉到函数内并缺包友好退出;Docker 预检下推到该子进程。tests/:改写启动测试覆盖 fail-fast;新增 subprocess 回归测试,用sys.modules['sandbox_docker_mcp']=None模拟缺包,证明默认导入路径不需要该 extra;adapter 测试加importorskip。docs:README 双语验证
pytest:312 passed(含新回归测试)demos/mock_e2e.py:MOCK E2E OK