LangSmith sandbox backend implementation.
Maximum size of a binary file returned by read() as base64.
Files exceeding this size return a Binary file exceeds maximum preview size
error rather than being base64-encoded in full. Backends overriding read()
should import and reuse this constant to stay in sync with the base
implementation. Kept in lockstep with the MAX_BINARY_BYTES literal in
_READ_COMMAND_TEMPLATE (asserted by test_read_constants_match_template).
Maximum size of rendered text content returned by read().
Pages exceeding this cap are truncated and TRUNCATION_MSG is appended.
Mirrors the MAX_OUTPUT_BYTES literal in _READ_COMMAND_TEMPLATE.
Sentinel appended to read() content when MAX_OUTPUT_BYTES is hit.
Result of code execution.
Simplified schema optimized for LLM consumption.
Data structure for storing file contents with metadata.
Result of a single file download operation.
The response is designed to allow partial success in batch operations.
The errors are standardized using FileOperationError literals for certain
recoverable conditions for use cases that involve LLMs performing
file operations.
Result of a single file upload operation.
The response is designed to allow partial success in batch operations.
The errors are standardized using FileOperationError literals for certain
recoverable conditions for use cases that involve LLMs performing
file operations.
Result from backend read operations.
Result from backend write operations.
Base sandbox implementation with execute() as the core abstract method.
This class provides default implementations for all protocol methods.
File listing, grep, and glob use shell commands via execute(). Read uses
a server-side Python script via execute() for paginated access. Write
delegates content transfer to upload_files(). Edit uses a server-side
script for small payloads and uploads old/new strings as temp files with
a server-side replace for large ones.
BaseSandbox does not reduce or partition the trust boundary of
execute(). Its helper methods are convenience wrappers built on top of
the subclass-provided command-execution primitive and assume callers who
can use BaseSandbox already have whatever shell-execution capability
that backend exposes.
Subclasses must implement execute(), upload_files(), download_files(),
and the id property.
LangSmith sandbox implementation conforming to SandboxBackendProtocol.