diff --git a/src/inspect_ai/util/_sandbox/environment.py b/src/inspect_ai/util/_sandbox/environment.py index ba32bb4502..25746d58b1 100644 --- a/src/inspect_ai/util/_sandbox/environment.py +++ b/src/inspect_ai/util/_sandbox/environment.py @@ -118,7 +118,15 @@ async def exec( The current working directory for execution will be the per-sample filesystem context. - By default, each output stream (stdout and stderr) is limited to 10 MiB. You can override this by setting the `INSPECT_SANDBOX_MAX_EXEC_OUTPUT_SIZE` environment variable (specified in bytes). If exceeded, an `OutputLimitExceededError` will be raised. + By default, each output stream (stdout and stderr) is limited to 10 MiB. You can override this by setting the `INSPECT_SANDBOX_MAX_EXEC_OUTPUT_SIZE` environment variable (specified in bytes). + + Behaviour above this limit depends on the sandbox provider. A provider may + raise `OutputLimitExceededError`, or return only the trailing portion of + the output with the beginning discarded. Callers should therefore not + assume that returned output is complete or rely on an exception to detect + overflow. This is particularly important when parsing structured output + such as JSON. For large output, write to a file and use `read_file()`, + which always raises `OutputLimitExceededError` when the limit is exceeded. Args: cmd: Command or command and arguments to execute. @@ -145,7 +153,7 @@ async def exec( characters which cannot be decoded. PermissionError: If the user does not have permission to execute the command. - OutputLimitExceededError: If an output stream + OutputLimitExceededError: May be raised if an output stream exceeds the limit. """ ...