infiniflow/ragflow · error · RuntimeError

Local execution output exceeded

Error message

Local execution output exceeded {self.max_output_bytes} bytes.

What it means

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().

Solutions

  1. 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).
  2. Increase 'max_output_bytes' at initialize() (schema max 10485760) if large stdout is legitimate.
  3. Silence noisy stderr in the child: lower log levels, disable progress bars (e.g. TQDM_DISABLE=1, TRANSFORMERS_VERBOSITY=error), redirect pip output.
  4. Return only a summary/pointer (path, row count, hash) from main() and fetch the full data via artifacts.

Example fix

# before (executed code)
print(json.dumps(huge_payload))

# after (executed code)
from pathlib import Path
Path('artifacts/output.json').write_text(json.dumps(huge_payload))
print(json.dumps({'status': 'ok', 'rows': len(huge_payload)}))
Defensive patterns

Strategy: try-catch

Try / catch

try:
    result = provider.execute_code(instance_id, code, "python")
except RuntimeError as e:
    if "output exceeded" in str(e):
        # rerun with quieter code or a higher cap; treat as workload error, not infra error
        raise OutputTooLarge(str(e)) from e
    raise

Prevention

When it happens

Trigger: 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().

Common situations: 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.

Related errors


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

Appendix: source

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

        import resource

        self._set_resource_limit(resource.RLIMIT_CPU, self.timeout + 1)
        self._set_resource_limit(resource.RLIMIT_AS, self.max_memory_mb * 1024 * 1024)
        self._set_resource_limit(resource.RLIMIT_FSIZE, self.max_artifact_bytes)
        self._set_resource_limit(resource.RLIMIT_NOFILE, 64)

    @staticmethod
    def _set_resource_limit(kind: int, value: int) -> None:
        import resource

        _, hard = resource.getrlimit(kind)
        limit = value if hard == resource.RLIM_INFINITY else min(value, hard)
        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}")

View on GitHub (pinned to 554fb1133a)