{"record":{"id":"be3e6b2136999a22","repo":"infiniflow/ragflow","slug":"ssh-execution-output-exceeded-self-max-output-byt","errorCode":null,"errorMessage":"SSH execution output exceeded {self.max_output_bytes} bytes.","messagePattern":"SSH execution output exceeded (.+?) bytes\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"warning","filePath":"agent/sandbox/providers/ssh.py","lineNumber":607,"sourceCode":"            if time.time() > deadline:\n                channel.close()\n                raise TimeoutError(f\"Execution timed out after {timeout} seconds\")\n            time.sleep(0.1)\n\n        while channel.recv_ready():\n            stdout_chunks.append(channel.recv(65536))\n        while channel.recv_stderr_ready():\n            stderr_chunks.append(channel.recv_stderr(65536))\n\n        exit_code = channel.recv_exit_status()\n        stdout = b\"\".join(stdout_chunks).decode(\"utf-8\", errors=\"replace\")\n        stderr = b\"\".join(stderr_chunks).decode(\"utf-8\", errors=\"replace\")\n        return stdout, stderr, exit_code\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\"SSH execution output exceeded {self.max_output_bytes} bytes.\")\n\n    def _collect_artifacts(\n        self,\n        sftp: paramiko.SFTPClient,\n        artifacts_dir: str,\n    ) -> list[dict[str, Any]]:\n        artifacts: list[dict[str, Any]] = []\n        self._collect_artifacts_recursive(sftp, artifacts_dir, \"\", artifacts)\n        return artifacts\n\n    def _collect_artifacts_recursive(\n        self,\n        sftp: paramiko.SFTPClient,\n        current_dir: str,\n        relative_dir: str,\n        artifacts: list[dict[str, Any]],\n    ) -> None:\n        try:","sourceCodeStart":589,"sourceCodeEnd":625,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/ssh.py#L589-L625","documentation":"Raised as RuntimeError by _validate_output_size after a command completes, when encoded stdout+stderr combined exceed self.max_output_bytes (default 1 MiB, configurable at initialize). It fires after execution succeeded — the process ran, output was captured, then rejected — so the run's output is lost when it raises. This guards the agent pipeline from multi-megabyte dumps entering structured-result extraction.","triggerScenarios":"Code that prints large data (dumping a DataFrame, cat-ing a big file, verbose logs); combining stdout and stderr just over the limit; lowering max_output_bytes in config below typical output size; the structured-result marker plus large payload.","commonSituations":"LLM code agents printing entire datasets instead of summaries; debugging prints left in generated code; default 1 MiB too small for legitimate CSV previews.","solutions":["Reduce output in the sandboxed code: print head()/summaries, write bulk data to files instead of stdout","Raise the limit at initialize: config {'max_output_bytes': 4*1024*1024} if the pipeline can absorb it","Capture stderr separately in your code so warnings don't inflate combined size"],"exampleFix":"# before\nprovider.execute_code(inst, \"print(open('big.csv').read())\", \"python\")\n\n# after\nprovider.execute_code(inst, \"print(open('big.csv').read()[:2000])\", \"python\")","handlingStrategy":"validation","validationCode":"estimated = len(stdout_text.encode()) + len(stderr_text.encode())\nif estimated > provider.max_output_bytes:\n    raise RuntimeError(\"output will exceed provider limit; print a summary instead\")","typeGuard":null,"tryCatchPattern":"try:\n    result = provider.execute_code(instance_id, code, language)\nexcept RuntimeError as e:\n    if \"exceeded\" in str(e) and \"bytes\" in str(e):\n        code = code.replace(\"print(df)\", \"print(df.head())\")\n        result = provider.execute_code(instance_id, code, language)","preventionTips":["Default sandboxed code to previews: head(), first N lines, truncated strings","Size max_output_bytes deliberately at initialize based on what downstream LLM context can absorb","Route bulk data to files/artifacts, not stdout"],"tags":["output-limits","validation","ssh","sandbox"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}