infiniflow/ragflow · warning · RuntimeError

SSH execution produced more than {self.max_artifacts} artifa

Error message

SSH execution produced more than {self.max_artifacts} artifacts.

What it means

Raised as RuntimeError during artifact collection when the number of already-collected artifacts reaches self.max_artifacts (default 20, configurable) and another regular file is found. It caps artifact count to bound response size and base64 encoding cost. The check fires before each append, so execution itself succeeded — only the artifact harvest is refused.

Source

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

            name = entry.filename
            remote_path = posixpath.join(current_dir, name)
            relative_path = posixpath.join(relative_dir, name) if relative_dir else name
            mode = entry.st_mode
            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,

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Write only the artifacts you need: delete intermediates before returning, or consolidate into one archive/file
  2. Raise the cap at initialize: config {'max_artifacts': 100} if the caller can handle the payload
  3. Keep package-manager/runtime caches out of the artifacts directory

Example fix

# before (sandboxed code): 50 pngs written
for i in range(50): plt.savefig(f'artifacts/p{i}.png')

# after: keep top 3
for i in range(3): plt.savefig(f'artifacts/p{i}.png')
Defensive patterns

Strategy: validation

Validate before calling

import os
files = [p for p in os.listdir(artifacts_dir) if os.path.isfile(os.path.join(artifacts_dir, p))]
if len(files) > provider.max_artifacts:
    raise RuntimeError(f"{len(files)} artifacts exceed limit {provider.max_artifacts}; prune before returning")

Try / catch

try:
    artifacts = provider.collect_artifacts(instance_id, artifacts_dir)
except RuntimeError as e:
    if "more than" in str(e) and "artifacts" in str(e):
        raise RuntimeError("too many output files; keep only essential artifacts") from e

Prevention

When it happens

Trigger: Sandboxed code writing more than 20 files into the artifacts directory (plots per category, per-page images, chunked exports); lowering max_artifacts in config below what the workflow normally emits; a runtime dropping many cache files into the collected tree.

Common situations: Chart-generation agents producing one PNG per series; scraping pipelines saving dozens of fragments; defaults too tight for batch report generation.

Related errors


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