{"record":{"id":"9fbcfdc7fa3178b7","repo":"infiniflow/ragflow","slug":"artifact-exceeds-self-max-artifact-bytes-bytes-9fbcfd","errorCode":null,"errorMessage":"Artifact exceeds {self.max_artifact_bytes} bytes: {relative_path}","messagePattern":"Artifact exceeds (.+?) bytes: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/tenki.py","lineNumber":476,"sourceCode":"        for entry in sorted(entries, key=lambda item: item.path):\n            name = posixpath.basename(entry.path)\n            remote_path = posixpath.join(current_dir, name)\n            relative_path = posixpath.join(relative_dir, name) if relative_dir else name\n\n            # Reject symlinks. `is_symlink` is not populated by every SDK\n            # release, so also inspect the stat mode bits as the reliable check.\n            if getattr(entry, \"is_symlink\", False) or stat.S_ISLNK(entry.mode or 0):\n                raise RuntimeError(f\"Artifact symlinks are not allowed: {relative_path}\")\n            if entry.is_dir:\n                self._collect_artifacts_recursive(sandbox, remote_path, relative_path, artifacts, depth + 1)\n                continue\n\n            if len(artifacts) >= self.max_artifacts:\n                raise RuntimeError(f\"Tenki execution produced more than {self.max_artifacts} artifacts.\")\n\n            size = int(entry.size or 0)\n            if size > self.max_artifact_bytes:\n                raise RuntimeError(f\"Artifact exceeds {self.max_artifact_bytes} bytes: {relative_path}\")\n\n            ext = os.path.splitext(name)[1].lower()\n            if ext not in ALLOWED_ARTIFACT_EXTENSIONS:\n                raise RuntimeError(f\"Unsupported artifact type: {relative_path}\")\n\n            content = sandbox.fs.read_bytes(remote_path)\n            artifacts.append(\n                {\n                    \"name\": relative_path,\n                    \"content_b64\": base64.b64encode(content).decode(\"ascii\"),\n                    \"mime_type\": mimetypes.guess_type(name)[0] or \"application/octet-stream\",\n                    \"size\": size,\n                }\n            )\n\n    def _safe_terminate(self, sandbox) -> None:\n        # Best-effort: max_lifetime reclaims the sandbox if this fails.\n        try:","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/tenki.py#L458-L494","documentation":"Raised during artifact collection when a single artifact file's entry.size exceeds max_artifact_bytes (default 10 MiB). The provider refuses to read_bytes() and base64-encode oversized files into the execution result.","triggerScenarios":"Script saves a large output file into artifacts/ — a big DataFrame CSV, a high-resolution PNG, a generated PDF — whose on-disk size is over the configured cap.","commonSituations":"Data-analysis code exporting full datasets, high-DPI plots, or max_output_bytes-style tuning done on the wrong knob (this cap is per-file, not per-stream).","solutions":["Reduce the file: sample/filter the data, compress images, or split into chunks within the cap.","Raise max_artifact_bytes in initialize() if large artifacts are expected and downstream consumers can handle the base64 payload (~1.33x size).","Keep oversized data in the sandbox and return only a path/summary, transferring via another channel if needed."],"exampleFix":"# before\n# script: df.to_csv('artifacts/full_export.csv')  # 500MB\n\n# after\n# config: max_artifact_bytes = 52428800\n# script: df.sample(100000).to_csv('artifacts/sample.csv')","handlingStrategy":"validation","validationCode":"# in generated code, check size before finishing:\n# for p in pathlib.Path('artifacts').rglob('*'):\n#     assert p.stat().st_size <= provider.max_artifact_bytes, p","typeGuard":null,"tryCatchPattern":"try:\n    result = provider.execute_code(instance_id, code)\nexcept RuntimeError as exc:\n    if \"Artifact exceeds\" in str(exc):\n        result = provider.execute_code(instance_id, sampled_or_compressed_version(code))\n    else:\n        raise","preventionTips":["Sample/filter large exports and compress images inside generated scripts.","Configure max_artifact_bytes to match real needs; remember base64 inflates payload by ~33%.","Return summaries plus artifact paths, not full datasets."],"tags":["artifacts","limits","file-size","tenki"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}