agentscope-ai/agentscope · error · RuntimeError
Bubblewrap write failed (exit {result.exit_code}): {result.s
Error message
Bubblewrap write failed (exit {result.exit_code}): {result.stderr.decode(errors='replace')} What it means
Generic RuntimeError raised by _write_via_cat when the sandboxed write command fails with an exit code other than 65. The message contains the exit status and decoded stderr of the sandboxed process, which usually pinpoints disk, permission, or bwrap launch problems.
Source
Thrown at src/agentscope/workspace/_bubblewrap/_bubblewrap_backend.py:328
"/workspace|/workspace/*|/tmp|/tmp/*) ;; "
"*) exit 65 ;; "
"esac; "
'mkdir -p -- "$resolved_parent" && '
'target="$resolved_parent/$(basename -- "$1")" && '
'[ ! -L "$target" ] || exit 65; '
'cat > "$target"'
),
"sh",
sandbox_path,
],
data,
)
if result.exit_code == 65:
raise PermissionError(
f"path escapes writable Bubblewrap mounts: {path}",
)
if not result.ok():
raise RuntimeError(
"Bubblewrap write failed "
f"(exit {result.exit_code}): "
f"{result.stderr.decode(errors='replace')}",
)
async def _exec_with_input(
self,
command: list[str],
data: bytes | AsyncIterator[bytes],
*,
cwd: str | None = None,
timeout: float | None = None,
) -> ExecResult:
"""Run a sandbox command with ``data`` piped to stdin.
An async iterator is fed chunk by chunk, so a large payload
never materializes. Safe only because the commands run this way
write nothing to stdout — otherwise a full pipe would deadlockView on GitHub (pinned to e90f1c7592)
Solutions
- Create parent directories inside the sandbox before writing
- Check the embedded stderr and host disk space (df -h on the workdir)
- Ensure the target path is not an existing directory
- Re-run bwrap manually to confirm the runtime is healthy
Example fix
# before
await ws.write_file('/workspace/a/b/c.txt', data) # a/b missing
# after
await ws.run_command('mkdir -p /workspace/a/b')
await ws.write_file('/workspace/a/b/c.txt', data) Defensive patterns
Strategy: fallback
Validate before calling
await ws.run_command(f'mkdir -p {posixpath.dirname(sandbox_path)}') # before write Type guard
null
Try / catch
try:
await ws.write_file(p, data)
except RuntimeError as e:
log.error('write failed: %s', e); raise Prevention
- Create parent directories before writes
- Monitor disk space on the host workdir backing store
When it happens
Trigger: Destination directory missing inside the sandbox, disk full, file exists as a directory, or bwrap failing to start the shell.
Common situations: Writing into a subdirectory never created in the sandbox, ENOSPC on the host backing the workdir bind mount, or a damaged bwrap runtime.
Related errors
- Bubblewrap read_file failed (exit {result.exit_code}): {resu
- basedir must not be empty.
- BubblewrapWorkspaceManager currently requires share_net=True
- Bubblewrap workdir escapes basedir.
- Failed to start container {self._container_name!r}: {stderr.
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/f517667ffdd02ad5.
Report an issue: GitHub.