infiniflow/ragflow · error · RuntimeError

Tenki execution produced more than {self.max_artifacts} arti

Error message

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

What it means

Raised during artifact collection when the number of collected files would exceed max_artifacts (default 20). Once the list already holds max_artifacts entries, the next file raises; the cap bounds memory and payload size when base64-encoding artifacts into the result.

Source

Thrown at agent/sandbox/providers/tenki.py:472

            return

        # fs.list returns each entry's basename in `.path`, not an absolute
        # path, so join it onto the directory being listed.
        for entry in sorted(entries, key=lambda item: item.path):
            name = posixpath.basename(entry.path)
            remote_path = posixpath.join(current_dir, name)
            relative_path = posixpath.join(relative_dir, name) if relative_dir else name

            # Reject symlinks. `is_symlink` is not populated by every SDK
            # release, so also inspect the stat mode bits as the reliable check.
            if getattr(entry, "is_symlink", False) or stat.S_ISLNK(entry.mode or 0):
                raise RuntimeError(f"Artifact symlinks are not allowed: {relative_path}")
            if entry.is_dir:
                self._collect_artifacts_recursive(sandbox, remote_path, relative_path, artifacts, depth + 1)
                continue

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

            size = int(entry.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}")

            content = sandbox.fs.read_bytes(remote_path)
            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. Make the script keep only the top max_artifacts outputs (delete intermediates, or write a single archive-free summary file).
  2. Raise max_artifacts in initialize() if the workload legitimately produces more files.
  3. Consolidate: pack results into one .csv/.json artifact instead of many files.

Example fix

# before
# script: for i in range(500): plt.savefig(f'artifacts/frame_{i}.png')

# after
# script: plt.savefig('artifacts/summary.png'); df.to_json('artifacts/results.json')
Defensive patterns

Strategy: validation

Validate before calling

# in generated code, prune artifacts to the cap before finishing:
# files = sorted(pathlib.Path('artifacts').rglob('*'))
# for p in files[provider.max_artifacts:]: p.unlink()

Try / catch

try:
    result = provider.execute_code(instance_id, code)
except RuntimeError as exc:
    if "more than" in str(exc) and "artifacts" in str(exc):
        result = provider.execute_code(instance_id, consolidated_artifacts_version(code))
    else:
        raise

Prevention

When it happens

Trigger: Script writes more than 20 files into artifacts/ — e.g. a loop emitting hundreds of PNGs, or copying a directory tree — and collection hits file number 21.

Common situations: Chart-generation code saving many small images, scraping jobs saving per-item files, or archive extraction into artifacts/ instead of selecting final outputs.

Related errors


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