infiniflow/ragflow · error · RuntimeError

Artifact exceeds {self.max_artifact_bytes} bytes: {relative_

Error message

Artifact exceeds {self.max_artifact_bytes} bytes: {relative_path}

What it means

Raised during artifact collection when a single file's `entry.size` (as reported by the sandbox file listing) exceeds `max_artifact_bytes` (default 10 MiB). The check uses the listing's metadata, so the file is rejected before its content is downloaded.

Source

Thrown at agent/sandbox/providers/ucloud_agent_sandbox.py:433

        if depth > MAX_ARTIFACT_DEPTH:
            raise RuntimeError(f"Artifact directory nesting exceeds {MAX_ARTIFACT_DEPTH} levels: {relative_dir}")
        sdk = _get_ucloud_sandbox_module()
        try:
            entries = sandbox.files.list(current_dir, depth=1, request_timeout=self.timeout)
        except sdk.FileNotFoundException:
            return
        for entry in sorted(entries, key=lambda item: item.path):
            name = posixpath.basename(entry.path)
            relative_path = posixpath.join(relative_dir, name) if relative_dir else name
            if entry.symlink_target is not None:
                raise RuntimeError(f"Artifact symlinks are not allowed: {relative_path}")
            if entry.type == sdk.FileType.DIR:
                self._collect_artifacts_recursive(sandbox, entry.path, relative_path, artifacts, depth + 1)
                continue
            if len(artifacts) >= self.max_artifacts:
                raise RuntimeError(f"UCloud Agent Sandbox execution produced more than {self.max_artifacts} artifacts.")
            if entry.size > self.max_artifact_bytes:
                raise RuntimeError(f"Artifact exceeds {self.max_artifact_bytes} bytes: {relative_path}")
            extension = os.path.splitext(name)[1].lower()
            if extension not in ALLOWED_ARTIFACT_EXTENSIONS:
                raise RuntimeError(f"Unsupported artifact type: {relative_path}")
            content = bytes(sandbox.files.read(entry.path, format="bytes", request_timeout=self.timeout))
            artifacts.append(
                {
                    "name": relative_path,
                    "content_b64": base64.b64encode(content).decode("ascii"),
                    "mime_type": mimetypes.guess_type(name)[0] or "application/octet-stream",
                    "size": entry.size,
                }
            )

    def _safe_kill(self, sandbox) -> None:
        """Best-effort terminate a remote sandbox during cleanup."""
        try:
            sandbox.kill(request_timeout=self.timeout)
        except Exception as exc:  # noqa: BLE001 - cleanup is deliberately best-effort

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Keep single artifacts under the cap (default 10 MiB); compress or downsample oversized outputs.
  2. Store large artifacts in external object storage and write only a reference/URL into artifacts.
  3. Raise `max_artifact_bytes` in the provider config if large artifacts are expected.
  4. Split a big file into chunks below the limit if the config cannot change.

Example fix

# before
open("artifacts/model.pkl", "wb").write(pickle.dumps(model))  # 80MiB -> RuntimeError

# after
open("artifacts/model_url.txt", "w").write(upload_to_s3(model))
Defensive patterns

Strategy: validation

Validate before calling

max_bytes = int(conf.get("max_artifact_bytes", 10 * 1024 * 1024))
import os
if os.path.getsize(path) > max_bytes:
    raise ValueError(f"{path} exceeds per-artifact cap {max_bytes}; upload externally")

Type guard

def is_artifact_size_error(exc: RuntimeError) -> bool:
    return "Artifact exceeds" in str(exc)

Try / catch

try:
    result = provider.execute(inst, code)
except RuntimeError as e:
    if "Artifact exceeds" in str(e):
        result = provider.execute(inst, compress_or_externalize_artifacts(code))
    else:
        raise

Prevention

When it happens

Trigger: Executed code writing a large file into artifacts — model checkpoints, datasets, images, logs, or dumps over the per-file cap.

Common situations: Scripts saving generated binaries (parquet/pickle/png) larger than 10 MiB; log files appended unbounded during long runs; default cap too small for media-generation workloads.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/f3feb067ff1ad2c5. Report an issue: GitHub.