{"record":{"id":"317171a101cda2ab","repo":"infiniflow/ragflow","slug":"artifact-exceeds-self-max-artifact-bytes-bytes","errorCode":null,"errorMessage":"Artifact exceeds {self.max_artifact_bytes} bytes: {path.name}","messagePattern":"Artifact exceeds (.+?) bytes: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/local.py","lineNumber":331,"sourceCode":"        if output_size > self.max_output_bytes:\n            raise RuntimeError(f\"Local execution output exceeded {self.max_output_bytes} bytes.\")\n\n    def _collect_artifacts(self, artifacts_dir: Path) -> list[dict[str, Any]]:\n        artifacts: list[dict[str, Any]] = []\n        for path in sorted(artifacts_dir.rglob(\"*\")):\n            if path.is_symlink():\n                raise RuntimeError(f\"Artifact symlinks are not allowed: {path.name}\")\n            if path.is_dir():\n                continue\n            if not path.is_file():\n                raise RuntimeError(f\"Unsupported artifact entry: {path.name}\")\n\n            if len(artifacts) >= self.max_artifacts:\n                raise RuntimeError(f\"Local execution produced more than {self.max_artifacts} artifacts.\")\n\n            size = path.stat().st_size\n            if size > self.max_artifact_bytes:\n                raise RuntimeError(f\"Artifact exceeds {self.max_artifact_bytes} bytes: {path.name}\")\n\n            ext = path.suffix.lower()\n            if ext not in ALLOWED_ARTIFACT_EXTENSIONS:\n                raise RuntimeError(f\"Unsupported artifact type: {path.name}\")\n\n            artifacts.append(\n                {\n                    \"name\": path.relative_to(artifacts_dir).as_posix(),\n                    \"content_b64\": base64.b64encode(path.read_bytes()).decode(\"ascii\"),\n                    \"mime_type\": mimetypes.guess_type(path.name)[0] or \"application/octet-stream\",\n                    \"size\": size,\n                }\n            )\n        return artifacts\n\n    @staticmethod\n    def _normalize_language(language: str) -> str:\n        lang_lower = (language or \"python\").lower()","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/local.py#L313-L349","documentation":"Raised by LocalProvider._collect_artifacts() when a single collected file's stat().st_size exceeds the configured max_artifact_bytes cap (default 10 MiB). It is checked before the extension allow-list, so an oversized file fails even with an allowed extension. The run fails during artifact collection; the file is not truncated or skipped.","triggerScenarios":"Executed code writing a large CSV/PNG/PDF into artifacts/ (e.g. a high-resolution matplotlib figure, full dataset export) exceeding the cap; lowering 'max_artifact_bytes' at initialize() below typical output sizes.","commonSituations":"Data exports of full result sets; high-DPI charts (figsize * dpi inflates PNG size); models or dataframes serialized to disk; a cap tuned for small text artifacts while the workload produces images.","solutions":["Shrink the output in the executed code: export a sample, downsample images (lower dpi), compress, or write a summary instead of full data.","Raise 'max_artifact_bytes' at initialize() (schema max 104857600) if large artifacts are expected.","Split oversized data across multiple files only if under max_artifacts, else aggregate to a compressed format (gzip/parquet).","Communicate the artifact budget to the code-generation step via prompt or arguments."],"exampleFix":"# before (executed code)\nplt.savefig('artifacts/chart.png', dpi=300)\n\n# after (executed code)\nplt.savefig('artifacts/chart.png', dpi=110)","handlingStrategy":"try-catch","validationCode":"# in the executed code, guard output size before finishing:\n# p = Path('out.png'); assert p.stat().st_size <= MAX_ARTIFACT_BYTES or shrink()","typeGuard":null,"tryCatchPattern":"try:\n    result = provider.execute_code(instance_id, code, \"python\")\nexcept RuntimeError as e:\n    if \"Artifact exceeds\" in str(e):\n        raise ArtifactTooLarge(str(e)) from e\n    raise","preventionTips":["Downsample/compress large outputs (dpi, image format, gzip) in the executed code.","Keep max_artifact_bytes comfortably above the biggest legitimate artifact.","Export samples or summaries instead of full datasets when sizes are unbounded."],"tags":["sandbox","artifacts","limits","local-provider"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}