infiniflow/ragflow · warning · RuntimeError

Artifact exceeds {self.max_artifact_bytes} bytes: {relative_

Error message

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

What it means

Raised as RuntimeError when a single artifact's st_size exceeds self.max_artifact_bytes (default 10 MiB, configurable at initialize). Each artifact is read fully into memory and base64-encoded into the result, so oversized files are rejected before the SFTP read. The message names the offending relative path and the byte limit.

Source

Thrown at agent/sandbox/providers/ssh.py:653

            if mode is None:
                mode = sftp.lstat(remote_path).st_mode
            if mode is None:
                raise RuntimeError(f"Unable to determine artifact entry type: {relative_path}")

            if stat.S_ISLNK(mode):
                raise RuntimeError(f"Artifact symlinks are not allowed: {relative_path}")
            if stat.S_ISDIR(mode):
                self._collect_artifacts_recursive(sftp, remote_path, relative_path, artifacts)
                continue
            if not stat.S_ISREG(mode):
                raise RuntimeError(f"Unsupported artifact entry: {relative_path}")

            if len(artifacts) >= self.max_artifacts:
                raise RuntimeError(f"SSH execution produced more than {self.max_artifacts} artifacts.")

            size = int(entry.st_size or 0)
            if size > self.max_artifact_bytes:
                raise RuntimeError(f"Artifact exceeds {self.max_artifact_bytes} bytes: {relative_path}")

            ext = os.path.splitext(name)[1].lower()
            if ext not in ALLOWED_ARTIFACT_EXTENSIONS:
                raise RuntimeError(f"Unsupported artifact type: {relative_path}")

            with sftp.file(remote_path, "rb") as artifact_file:
                content = artifact_file.read()

            artifacts.append(
                {
                    "name": relative_path,
                    "content_b64": base64.b64encode(content).decode("ascii"),
                    "mime_type": mimetypes.guess_type(name)[0] or "application/octet-stream",
                    "size": size,
                }
            )

    @staticmethod

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Shrink the artifact in sandboxed code: downsample images, gzip + rename, or truncate datasets to a preview
  2. Raise the cap at initialize: config {'max_artifact_bytes': 50*1024*1024} when the consumer can handle it
  3. Upload large outputs to object storage from inside the sandbox and emit only a reference artifact

Example fix

# before (sandboxed code)
df.to_csv('artifacts/full.csv')  # 200MB

# after (sandboxed code)
df.head(1000).to_csv('artifacts/preview.csv')
Defensive patterns

Strategy: validation

Validate before calling

import os
for f in os.listdir(artifacts_dir):
    if os.path.getsize(os.path.join(artifacts_dir, f)) > provider.max_artifact_bytes:
        raise RuntimeError(f"{f} exceeds per-artifact limit; downsample or move to object storage")

Try / catch

try:
    artifacts = provider.collect_artifacts(instance_id, artifacts_dir)
except RuntimeError as e:
    if "Artifact exceeds" in str(e):
        raise RuntimeError("artifact too large; emit a preview or reference instead") from e

Prevention

When it happens

Trigger: Sandboxed code writing a large dataset/plot/PDF into the artifacts dir; generated code exporting full-resolution images; lowering max_artifact_bytes in config; sparse files reporting large st_size.

Common situations: Data-analysis agents exporting whole CSVs as artifacts instead of samples; high-DPI matplotlib figures; PDF reports with embedded images exceeding 10 MiB.

Related errors


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