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 artifactsView on GitHub (pinned to 554fb1133a)
Solutions
- Reduce file count in the executed code: aggregate into one archive or single CSV/JSON, or keep only the top-N outputs.
- Raise 'max_artifacts' at initialize() if many files are expected (schema max 100).
- 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.
- 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
- Aggregate many small outputs into one file in the executed code.
- Pass the artifact budget into code-generation prompts.
- Set max_artifacts from measured workload needs, not the default, when generating batches of files.
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
- Artifact exceeds {self.max_artifact_bytes} bytes: {path.name
- SANDBOX_LOCAL_MAX_ARTIFACTS must be greater than or equal to
- SANDBOX_LOCAL_MAX_ARTIFACT_BYTES must be greater than 0.
- Local execution output exceeded {self.max_output_bytes} byte
- Artifact symlinks are not allowed: {path.name}
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/e3b38184067e328a.
Report an issue: GitHub.