{"record":{"id":"f531ef78ebd8e797","repo":"infiniflow/ragflow","slug":"local-execution-output-exceeded-self-max-output-b","errorCode":null,"errorMessage":"Local execution output exceeded {self.max_output_bytes} bytes.","messagePattern":"Local execution output exceeded (.+?) bytes\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/local.py","lineNumber":314,"sourceCode":"        import resource\n\n        self._set_resource_limit(resource.RLIMIT_CPU, self.timeout + 1)\n        self._set_resource_limit(resource.RLIMIT_AS, self.max_memory_mb * 1024 * 1024)\n        self._set_resource_limit(resource.RLIMIT_FSIZE, self.max_artifact_bytes)\n        self._set_resource_limit(resource.RLIMIT_NOFILE, 64)\n\n    @staticmethod\n    def _set_resource_limit(kind: int, value: int) -> None:\n        import resource\n\n        _, hard = resource.getrlimit(kind)\n        limit = value if hard == resource.RLIM_INFINITY else min(value, hard)\n        resource.setrlimit(kind, (limit, limit))\n\n    def _validate_output_size(self, stdout: str, stderr: str) -> None:\n        output_size = len((stdout or \"\").encode(\"utf-8\")) + len((stderr or \"\").encode(\"utf-8\"))\n        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","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/local.py#L296-L332","documentation":"Raised by LocalProvider._validate_output_size() after a child process finishes, when the combined UTF-8 byte length of captured stdout and stderr exceeds max_output_bytes (default 1 MiB). It fires after process completion (not during), so the process already ran to completion or its own timeout; the whole execution result is discarded and RuntimeError propagates from execute_code().","triggerScenarios":"Generated code that prints large dataframes, long lists, base64 blobs, or verbose install/logging output; combining a chatty library (pip, transformers, debug logging) on stderr with prints on stdout; a low max_output_bytes configured at initialize().","commonSituations":"Agent-written code doing print(df) or print(json.dumps(big_payload)); ML libraries emitting progress bars/warnings to stderr; forgetting that stderr counts toward the same budget; setting max_output_bytes near the 1024 minimum.","solutions":["Make the executed code write large outputs to files in the artifacts directory instead of stdout (files are governed by artifact limits, not output limits).","Increase 'max_output_bytes' at initialize() (schema max 10485760) if large stdout is legitimate.","Silence noisy stderr in the child: lower log levels, disable progress bars (e.g. TQDM_DISABLE=1, TRANSFORMERS_VERBOSITY=error), redirect pip output.","Return only a summary/pointer (path, row count, hash) from main() and fetch the full data via artifacts."],"exampleFix":"# before (executed code)\nprint(json.dumps(huge_payload))\n\n# after (executed code)\nfrom pathlib import Path\nPath('artifacts/output.json').write_text(json.dumps(huge_payload))\nprint(json.dumps({'status': 'ok', 'rows': len(huge_payload)}))","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = provider.execute_code(instance_id, code, \"python\")\nexcept RuntimeError as e:\n    if \"output exceeded\" in str(e):\n        # rerun with quieter code or a higher cap; treat as workload error, not infra error\n        raise OutputTooLarge(str(e)) from e\n    raise","preventionTips":["Instruct generated code to avoid printing raw large payloads; use artifacts files instead.","Silence chatty stderr sources (progress bars, pip, warnings) in the child environment.","Set max_output_bytes proportional to expected output and monitor near-limit runs."],"tags":["sandbox","local-provider","output-limits","stdout","limits"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}