agentscope-ai/agentscope · error · RuntimeError

write to {path!r} failed: {command[0]} exited {exit_code}: {

Error message

write to {path!r} failed: {command[0]} exited {exit_code}: {stderr_text}

What it means

Raised when a write into the Kubernetes workspace Pod fails: the command used to receive the tar stream (e.g. tar or dd) exited with a non-zero status and its stderr is included in the message. The library pipes an in-memory tar archive over WebSocket stdin to a command inside the Pod, so failures come from the container side (disk full, read-only filesystem, missing tar binary, permission denied).

Source

Thrown at src/agentscope/workspace/_k8s/_k8s_backend.py:407

                        import json

                        try:
                            status = json.loads(
                                payload.decode("utf-8"),
                            )
                            if status.get("status") != "Success":
                                exit_code = 1
                        except (
                            json.JSONDecodeError,
                            ValueError,
                        ):
                            exit_code = 1

            if exit_code != 0:
                stderr_text = b"".join(stderr_parts).decode(
                    errors="replace",
                )
                raise RuntimeError(
                    f"write to {path!r} failed: "
                    f"{command[0]} exited {exit_code}: {stderr_text}",
                )

View on GitHub (pinned to e90f1c7592)

Solutions

  1. Run 'kubectl exec <pod> -- df -h' and enlarge the PVC or prune files if disk is full
  2. Verify tar exists in the image (kubectl exec <pod> -- which tar); switch to an image that includes it
  3. Write only inside the mounted workspace volume and check directory permissions/ownership
  4. Align securityContext runAsUser/fsGroup with the volume's file ownership

Example fix

# before
await ws.write_file("/workspace/big.bin", data)  # RuntimeError: tar exited 1: No space left on device

# after
# enlarge PVC (or clean up) then retry with a guard
try:
    await ws.write_file("/workspace/big.bin", data)
except RuntimeError as e:
    logging.warning("pod write failed: %s", e)
    await cleanup_workspace(ws)
Defensive patterns

Strategy: try-catch

Validate before calling

null

Try / catch

try:
    await ws.write_file(path, data)
except RuntimeError as e:
    log.error("pod write failed: %s", e)
    # inspect stderr in message: disk-full / read-only / permission
    raise

Prevention

When it happens

Trigger: write_file or write_stream to a path on a full PVC (exit code from tar: 'No space left on device'); target filesystem mounted read-only; the 'tar' binary missing in a minimal/distroless image; permission errors writing to a path owned by another UID.

Common situations: Small PVC requests that fill up with agent artifacts; distroless or scratch images without tar; securityContext running as non-root while the volume is root-owned; writing outside the mounted volume into an immutable layer.

Related errors


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