{"record":{"id":"4f1c1e0862af656f","repo":"infiniflow/ragflow","slug":"tenki-execution-output-exceeded-self-max-output-b","errorCode":null,"errorMessage":"Tenki execution output exceeded {self.max_output_bytes} bytes.","messagePattern":"Tenki execution output exceeded (.+?) bytes\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"warning","filePath":"agent/sandbox/providers/tenki.py","lineNumber":437,"sourceCode":"        if language == \"python\":\n            script_name = \"main.py\"\n            script_content = build_python_wrapper(code, args_json)\n            executable = \"python3\"\n        elif language in {\"javascript\", \"nodejs\"}:\n            script_name = \"main.js\"\n            script_content = build_javascript_wrapper(code, args_json)\n            executable = \"node\"\n        else:\n            raise RuntimeError(f\"Unsupported language for Tenki provider: {language}\")\n\n        script_path = posixpath.join(remote_work_dir, script_name)\n        sandbox.fs.write_text(script_path, script_content)\n        return script_path, [executable, script_path]\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\"Tenki execution output exceeded {self.max_output_bytes} bytes.\")\n\n    def _collect_artifacts(self, sandbox, artifacts_dir: str) -> list[dict[str, Any]]:\n        artifacts: list[dict[str, Any]] = []\n        self._collect_artifacts_recursive(sandbox, artifacts_dir, \"\", artifacts, depth=0)\n        return artifacts\n\n    def _collect_artifacts_recursive(self, sandbox, current_dir: str, relative_dir: str, artifacts: list[dict[str, Any]], depth: int) -> None:\n        if depth > MAX_ARTIFACT_DEPTH:\n            raise RuntimeError(f\"Artifact directory nesting exceeds {MAX_ARTIFACT_DEPTH} levels: {relative_dir}\")\n\n        errors = self._tenki_errors()\n        try:\n            entries = sandbox.fs.list(current_dir)\n        except errors.FileNotFoundError:\n            return\n        except FileNotFoundError:\n            return\n","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/tenki.py#L419-L455","documentation":"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.","triggerScenarios":"Scripts that print large dumps (entire DataFrames, big JSON, hexdumps, progress spam in a loop) exceeding the cap in combined stdout+stderr bytes.","commonSituations":"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.","solutions":["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.","Raise max_output_bytes in initialize() if larger outputs are expected and the agent context can absorb them.","Capture stderr separately in the script or lower library verbosity to keep the combined size under the cap."],"exampleFix":"# before\n# script: print(df.to_string())  # 50MB -> error\n\n# after\n# script: df.to_csv('artifacts/result.csv', index=False); print(df.describe())","handlingStrategy":"validation","validationCode":"# in generated scripts, bound output before returning\n# import sys; sys.stdout.write(big_text[:100000])\n# and pre-check provider cap:\nassert 0 < provider.max_output_bytes, \"bad cap\"","typeGuard":null,"tryCatchPattern":"try:\n    result = provider.execute_code(instance_id, code)\nexcept RuntimeError as exc:\n    if \"output exceeded\" in str(exc):\n        code2 = code + \"\\nimport sys; sys.stdout.truncate(100000)\"  # or regenerate\n        result = provider.execute_code(instance_id, code2)\n    else:\n        raise","preventionTips":["Instruct generated code to print summaries and write bulk data as .csv/.json artifacts.","Size max_output_bytes in initialize() to the real expected output, not the default 1 MiB.","Silence verbose libraries' stderr inside scripts."],"tags":["limits","output-size","execution","tenki"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}