infiniflow/ragflow · warning · RuntimeError

Tenki execution output exceeded {self.max_output_bytes} byte

Error message

Tenki execution output exceeded {self.max_output_bytes} bytes.

What it means

Raised by _validate_output_size() after a run: the UTF-8 byte length of stdout plus stderr exceeds max_output_bytes (default 1 MiB). It exists to stop unbounded script output from being pulled into the agent context; the check runs before extract_structured_result(), so the whole execution is discarded.

Source

Thrown at agent/sandbox/providers/tenki.py:437

        if language == "python":
            script_name = "main.py"
            script_content = build_python_wrapper(code, args_json)
            executable = "python3"
        elif language in {"javascript", "nodejs"}:
            script_name = "main.js"
            script_content = build_javascript_wrapper(code, args_json)
            executable = "node"
        else:
            raise RuntimeError(f"Unsupported language for Tenki provider: {language}")

        script_path = posixpath.join(remote_work_dir, script_name)
        sandbox.fs.write_text(script_path, script_content)
        return script_path, [executable, script_path]

    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"Tenki execution output exceeded {self.max_output_bytes} bytes.")

    def _collect_artifacts(self, sandbox, artifacts_dir: str) -> list[dict[str, Any]]:
        artifacts: list[dict[str, Any]] = []
        self._collect_artifacts_recursive(sandbox, artifacts_dir, "", artifacts, depth=0)
        return artifacts

    def _collect_artifacts_recursive(self, sandbox, current_dir: str, relative_dir: str, artifacts: list[dict[str, Any]], depth: int) -> None:
        if depth > MAX_ARTIFACT_DEPTH:
            raise RuntimeError(f"Artifact directory nesting exceeds {MAX_ARTIFACT_DEPTH} levels: {relative_dir}")

        errors = self._tenki_errors()
        try:
            entries = sandbox.fs.list(current_dir)
        except errors.FileNotFoundError:
            return
        except FileNotFoundError:
            return

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Trim script output: write large results to an artifact file (allowed extensions include .csv/.json) instead of printing, print summaries, or head()/tail() the data.
  2. Raise max_output_bytes in initialize() if larger outputs are expected and the agent context can absorb them.
  3. Capture stderr separately in the script or lower library verbosity to keep the combined size under the cap.

Example fix

# before
# script: print(df.to_string())  # 50MB -> error

# after
# script: df.to_csv('artifacts/result.csv', index=False); print(df.describe())
Defensive patterns

Strategy: validation

Validate before calling

# in generated scripts, bound output before returning
# import sys; sys.stdout.write(big_text[:100000])
# and pre-check provider cap:
assert 0 < provider.max_output_bytes, "bad cap"

Try / catch

try:
    result = provider.execute_code(instance_id, code)
except RuntimeError as exc:
    if "output exceeded" in str(exc):
        code2 = code + "\nimport sys; sys.stdout.truncate(100000)"  # or regenerate
        result = provider.execute_code(instance_id, code2)
    else:
        raise

Prevention

When it happens

Trigger: Scripts that print large dumps (entire DataFrames, big JSON, hexdumps, progress spam in a loop) exceeding the cap in combined stdout+stderr bytes.

Common situations: LLM-generated data-analysis code doing print(df) on large tables, verbose libraries writing to stderr, or a too-low max_output_bytes set in config while legitimate output is larger.

Related errors


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