Build and run agents you can see, understand and trust.
Python agentchatbotlarge-language-modelsllmllm-agentmcpmulti-agentmulti-modalreact-agentrealtime-agentvoice-agentvoice-assistant
fix(workspace): fix OpenSandbox bootstrap and state filtering (#2046)
Wenxiang Jin89febfb2412a
diff --git a/src/agentscope/workspace/_opensandbox/_constants.py b/src/agentscope/workspace/_opensandbox/_constants.pyindex 5f5f1b213..e434db68b 100644--- a/src/agentscope/workspace/_opensandbox/_constants.py+++ b/src/agentscope/workspace/_opensandbox/_constants.py@@ -12,7 +12,7 @@ base class, not here.#: Default OpenSandbox image. The slim Python image is small but still#: has enough package-manager support for installing curl, certificates,-#: ripgrep, and procps during bootstrap.+#: and ripgrep during bootstrap.DEFAULT_IMAGE = "python:3.11-slim"#: Default keep-alive timeout in seconds for newly-created sandboxes.diff --git a/src/agentscope/workspace/_opensandbox/_opensandbox_workspace.py b/src/agentscope/workspace/_opensandbox/_opensandbox_workspace.pyindex fbb5e0622..359c4802e 100644--- a/src/agentscope/workspace/_opensandbox/_opensandbox_workspace.py+++ b/src/agentscope/workspace/_opensandbox/_opensandbox_workspace.py@@ -226,14 +226,14 @@ class OpenSandboxWorkspace(SandboxedWorkspaceBase):async def _find_existing_sandbox(self) -> SandboxInfo | None:"""Return the most recent sandbox matching this workspace id."""- from opensandbox.models.sandboxes import SandboxFilter+ from opensandbox.models.sandboxes import SandboxFilter, SandboxStatefrom opensandbox import SandboxManagermanager = await SandboxManager.create(connection_config=self._connection_config(),)sandbox_filter = SandboxFilter(- states=["RUNNING", "PAUSED"],+ states=[SandboxState.RUNNING, SandboxState.PAUSED],metadata={METADATA_WORKSPACE_ID_KEY: self.workspace_id},)try:@@ -382,19 +382,19 @@ class OpenSandboxWorkspace(SandboxedWorkspaceBase):pip_args = " ".join(shlex.quote(p) for p in pip_pkgs)return [- # 1. System packages used by bootstrap and builtin tools. The- # default image runs as root, so no sudo is needed. ``procps``- # backs gateway-process cleanup; ``ripgrep`` backs the Grep tool.+ # System packages used by bootstrap and builtin tools. The+ # default image runs as root, so no sudo is needed. ``ripgrep``+ # backs the Grep tool."apt-get update -qq ""&& apt-get install -y --no-install-recommends curl "- "ca-certificates procps ripgrep "+ "ca-certificates ripgrep ""&& rm -rf /var/lib/apt/lists/*",- # 2. Astral uv → /usr/local/bin (on PATH). INSTALLER_NO_MODIFY_PATH+ # Astral uv → /usr/local/bin (on PATH). INSTALLER_NO_MODIFY_PATH# suppresses shell rc edits."curl -LsSf https://astral.sh/uv/install.sh ""| env UV_INSTALL_DIR=/usr/local/bin ""INSTALLER_NO_MODIFY_PATH=1 sh",- # 3. Gateway venv + base requirements + agentscope from PyPI.+ # Gateway venv + base requirements + agentscope from PyPI.# ``uv venv`` creates the gateway home as a parent dir.f"uv venv {self._gateway_venv}",f"uv pip install --python {self._gateway_python} {pip_args}",