infiniflow/ragflow · error · RuntimeError

Local execution produced more than {self.max_artifacts} arti

Error message

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

What it means

Raised by LocalProvider._collect_artifacts() when the artifacts directory contains more collectible files than the configured max_artifacts cap (default 20). The check fires when appending the (max+1)-th file — directories are skipped and invalid entries fail earlier, so this counts regular files with allowed handling up to that point. The whole run fails; no partial artifact list is returned.

Source

Thrown at agent/sandbox/providers/local.py:327

        resource.setrlimit(kind, (limit, limit))

    def _validate_output_size(self, stdout: str, stderr: str) -> None:
        output_size = len((stdout or "").encode("utf-8")) + len((stderr or "").encode("utf-8"))
        if output_size > self.max_output_bytes:
            raise RuntimeError(f"Local execution output exceeded {self.max_output_bytes} bytes.")

    def _collect_artifacts(self, artifacts_dir: Path) -> list[dict[str, Any]]:
        artifacts: list[dict[str, Any]] = []
        for path in sorted(artifacts_dir.rglob("*")):
            if path.is_symlink():
                raise RuntimeError(f"Artifact symlinks are not allowed: {path.name}")
            if path.is_dir():
                continue
            if not path.is_file():
                raise RuntimeError(f"Unsupported artifact entry: {path.name}")

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

            size = path.stat().st_size
            if size > self.max_artifact_bytes:
                raise RuntimeError(f"Artifact exceeds {self.max_artifact_bytes} bytes: {path.name}")

            ext = path.suffix.lower()
            if ext not in ALLOWED_ARTIFACT_EXTENSIONS:
                raise RuntimeError(f"Unsupported artifact type: {path.name}")

            artifacts.append(
                {
                    "name": path.relative_to(artifacts_dir).as_posix(),
                    "content_b64": base64.b64encode(path.read_bytes()).decode("ascii"),
                    "mime_type": mimetypes.guess_type(path.name)[0] or "application/octet-stream",
                    "size": size,
                }
            )
        return artifacts

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Reduce file count in the executed code: aggregate into one archive or single CSV/JSON, or keep only the top-N outputs.
  2. Raise 'max_artifacts' at initialize() if many files are expected (schema max 100).
  3. Set 'max_artifacts': 0 and skip artifact collection if artifacts are not needed — note this check only triggers when collection runs with cap 0 and any file exists, so also ensure artifacts/ stays empty.
  4. Pass the cap into the code-generation prompt so the model knows the budget.

Example fix

# before (executed code)
for i in range(50):
    df[i].to_csv(f'artifacts/part_{i}.csv')

# after (executed code)
import pandas as pd
pd.concat(df).to_csv('artifacts/all_parts.csv')
Defensive patterns

Strategy: validation

Validate before calling

# in the executed code, before returning:
# n = len(list(Path('artifacts').iterdir())); assert n <= MAX_ARTIFACTS

Try / catch

try:
    result = provider.execute_code(instance_id, code, "python")
except RuntimeError as e:
    if "more than" in str(e) and "artifacts" in str(e):
        raise TooManyArtifacts(str(e)) from e
    raise

Prevention

When it happens

Trigger: Executed code writing 21+ files into artifacts/ with max_artifacts left at default; lowering 'max_artifacts' at initialize() while generated code writes many plots/CSV shards; batch jobs emitting one file per iteration.

Common situations: LLM-generated loops saving a figure per step; sharding a dataset into many part files; a low cap configured to keep responses small while the code has no notion of the cap.

Related errors


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