BerriAI/litellm · error · ValueError

Sandbox output exceeded

Error message

Sandbox output exceeded {SANDBOX_MAX_OUTPUT_BYTES} bytes; aborting to avoid unbounded memory use.

What it means

Guard inside _read_capped_lines: while streaming sandbox execution output, the cumulative byte count of decoded lines exceeded the SANDBOX_MAX_OUTPUT_BYTES limit, so the read is aborted to prevent unbounded memory consumption from a runaway process.

Solutions

  1. Reduce the amount of output the sandboxed code produces (write to files instead of stdout).
  2. Raise SANDBOX_MAX_OUTPUT_BYTES if larger outputs are expected and memory allows.
  3. Truncate or paginate output within the sandboxed program.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/base_llm/sandbox/transformation.py:88 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/765754447c0be3fc. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/base_llm/sandbox/transformation.py:88

    ) -> CodeExecutionResult:
        raise NotImplementedError("arun_code must be implemented by provider")

    async def adelete_sandbox(
        self,
        *,
        container: ContainerHandle | str,
        api_key: str | None = None,
        **kwargs,
    ) -> bool:
        raise NotImplementedError("adelete_sandbox must be implemented by provider")

    async def _read_capped_lines(self, response: httpx.Response) -> list[str]:
        lines: Final[list[str]] = []
        total = 0
        async for line in response.aiter_lines():
            total += len(line.encode("utf-8"))
            if total > SANDBOX_MAX_OUTPUT_BYTES:
                raise ValueError(
                    f"Sandbox output exceeded {SANDBOX_MAX_OUTPUT_BYTES} bytes; aborting to avoid unbounded memory use."
                )
            lines.append(line)
        return lines

View on GitHub (pinned to 77b7c6c40c)