agentscope-ai/agentscope · error · ValueError

host_workdir must not be empty.

Error message

host_workdir must not be empty.

What it means

host_workdir is validated to be non-empty after stripping whitespace. Passing '' or ' ' is rejected because a blank path cannot anchor the host-side workspace directory.

Source

Thrown at src/agentscope/workspace/_bubblewrap/_bubblewrap_workspace.py:134

                For a persistent ``host_workdir``, keep this list stable
                across workspace instances; changing it does not currently
                invalidate an existing Bootstrap environment.
            instructions (`str`, optional):
                System-prompt fragment template.
            default_mcps (`list[MCPClient] | None`, optional):
                MCPs seeded on first initialization.
            skill_paths (`list[str] | None`, optional):
                Local skill directories seeded on first initialization.
        """
        self._validate_gateway_port(gateway_port)
        if not share_net:
            raise ValueError(
                "BubblewrapWorkspace currently requires share_net=True "
                "because its TCP MCP gateway must be reachable across "
                "separate bwrap executions.",
            )
        if host_workdir is not None and not host_workdir.strip():
            raise ValueError("host_workdir must not be empty.")
        if host_cache_dir is not None and not host_cache_dir.strip():
            raise ValueError("host_cache_dir must not be empty.")

        super().__init__(
            workspace_id=workspace_id,
            default_mcps=default_mcps,
            skill_paths=skill_paths,
        )

        self.workdir = SANDBOX_WORKDIR
        self.gateway_port = gateway_port
        self._gateway_port_input = gateway_port
        self._gateway_token = ""
        self._gateway_nonce = ""
        self._rotate_gateway_credentials()
        self.share_net = share_net
        self.env = dict(env or {})
        self.extra_pip = list(extra_pip or [])

View on GitHub (pinned to e90f1c7592)

Solutions

  1. Supply a real absolute path, or pass None to let the workspace create and own a temp directory
  2. Guard config: value = cfg.get('host_workdir') or None before constructing

Example fix

# before
ws = BubblewrapWorkspace(host_workdir=os.environ.get('WS_DIR', ''))
# after
ws = BubblewrapWorkspace(host_workdir=os.environ.get('WS_DIR') or None)
Defensive patterns

Strategy: validation

Validate before calling

host_workdir = host_workdir.strip() if host_workdir and host_workdir.strip() else None

Type guard

def non_empty_or_none(v: str | None) -> str | None:
    return v.strip() or None if isinstance(v, str) else None

Try / catch

null

Prevention

When it happens

Trigger: BubblewrapWorkspace(host_workdir='') or host_workdir=' '; commonly from unfilled config/env vars defaulting to empty strings.

Common situations: os.environ.get('WORKDIR', '') or empty fields in YAML/TOML config feeding the constructor.

Related errors


AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28). Data as JSON: /api/errors/aad9b1af9c654d1c. Report an issue: GitHub.