mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-04 18:22:10 +00:00
fix: avoid ARG_MAX on sandbox writes by using SDK write()
This commit is contained in:
parent
1ecf8306a7
commit
838e042fe4
2 changed files with 25 additions and 14 deletions
|
|
@ -16,11 +16,12 @@ from deepagents.backends.protocol import (
|
||||||
FileDownloadResponse,
|
FileDownloadResponse,
|
||||||
FileUploadResponse,
|
FileUploadResponse,
|
||||||
SandboxBackendProtocol,
|
SandboxBackendProtocol,
|
||||||
|
WriteResult,
|
||||||
)
|
)
|
||||||
from deepagents.backends.sandbox import BaseSandbox
|
from deepagents.backends.sandbox import BaseSandbox
|
||||||
|
|
||||||
from langsmith.sandbox import Sandbox, SandboxClient, SandboxTemplate
|
if TYPE_CHECKING:
|
||||||
|
from langsmith.sandbox import Sandbox, SandboxClient, SandboxTemplate
|
||||||
|
|
||||||
|
|
||||||
class SandboxProvider(ABC):
|
class SandboxProvider(ABC):
|
||||||
|
|
@ -82,14 +83,25 @@ class LangSmithBackend(BaseSandbox):
|
||||||
truncated=False,
|
truncated=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def write(self, file_path: str, content: str) -> WriteResult:
|
||||||
|
"""Write content using the LangSmith SDK to avoid ARG_MAX.
|
||||||
|
|
||||||
|
BaseSandbox.write() sends the full content in a shell command, which
|
||||||
|
can exceed ARG_MAX for large content. This override uses the SDK's
|
||||||
|
native write(), which sends content in the HTTP body.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
self._sandbox.write(file_path, content.encode("utf-8"))
|
||||||
|
return WriteResult(path=file_path, files_update=None)
|
||||||
|
except Exception as e:
|
||||||
|
return WriteResult(error=f"Failed to write file '{file_path}': {e}")
|
||||||
|
|
||||||
def download_files(self, paths: list[str]) -> list[FileDownloadResponse]:
|
def download_files(self, paths: list[str]) -> list[FileDownloadResponse]:
|
||||||
"""Download multiple files from the LangSmith sandbox."""
|
"""Download multiple files from the LangSmith sandbox."""
|
||||||
responses: list[FileDownloadResponse] = []
|
responses: list[FileDownloadResponse] = []
|
||||||
for path in paths:
|
for path in paths:
|
||||||
content = self._sandbox.read(path)
|
content = self._sandbox.read(path)
|
||||||
responses.append(
|
responses.append(FileDownloadResponse(path=path, content=content, error=None))
|
||||||
FileDownloadResponse(path=path, content=content, error=None)
|
|
||||||
)
|
|
||||||
return responses
|
return responses
|
||||||
|
|
||||||
def upload_files(self, files: list[tuple[str, bytes]]) -> list[FileUploadResponse]:
|
def upload_files(self, files: list[tuple[str, bytes]]) -> list[FileUploadResponse]:
|
||||||
|
|
@ -148,10 +160,7 @@ class LangSmithProvider(SandboxProvider):
|
||||||
template_name=resolved_template_name, timeout=timeout
|
template_name=resolved_template_name, timeout=timeout
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = (
|
msg = f"Failed to create sandbox from template '{resolved_template_name}': {e}"
|
||||||
f"Failed to create sandbox from template "
|
|
||||||
f"'{resolved_template_name}': {e}"
|
|
||||||
)
|
|
||||||
raise RuntimeError(msg) from e
|
raise RuntimeError(msg) from e
|
||||||
|
|
||||||
# Verify sandbox is ready by polling
|
# Verify sandbox is ready by polling
|
||||||
|
|
|
||||||
8
apps/agent/uv.lock
generated
8
apps/agent/uv.lock
generated
|
|
@ -976,7 +976,7 @@ wheels = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "langsmith"
|
name = "langsmith"
|
||||||
version = "0.6.9"
|
version = "0.7.1"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "httpx" },
|
{ name = "httpx" },
|
||||||
|
|
@ -989,9 +989,9 @@ dependencies = [
|
||||||
{ name = "xxhash" },
|
{ name = "xxhash" },
|
||||||
{ name = "zstandard" },
|
{ name = "zstandard" },
|
||||||
]
|
]
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/9a/e0/463a70b43d6755b01598bb59932eec8e2029afcab455b5312c318ac457b5/langsmith-0.6.9.tar.gz", hash = "sha256:aae04cec6e6d8e133f63ba71c332ce0fbd2cda95260db7746ff4c3b6a3c41db1", size = 973557, upload-time = "2026-02-05T20:10:55.629Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/67/48/3151de6df96e0977b8d319b03905e29db0df6929a85df1d922a030b7e68d/langsmith-0.7.1.tar.gz", hash = "sha256:e3fec2f97f7c5192f192f4873d6a076b8c6469768022323dded07087d8cb70a4", size = 984367, upload-time = "2026-02-10T01:55:24.696Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/e6/8e/063e09c5e8a3dcd77e2a8f0bff3f71c1c52a9d238da1bcafd2df3281da17/langsmith-0.6.9-py3-none-any.whl", hash = "sha256:86ba521e042397f6fbb79d63991df9d5f7b6a6dd6a6323d4f92131291478dcff", size = 319228, upload-time = "2026-02-05T20:10:54.248Z" },
|
{ url = "https://files.pythonhosted.org/packages/ce/87/6f2b008a456b4f5fd0fb1509bb7e1e9368c1a0c9641a535f224a9ddc10f3/langsmith-0.7.1-py3-none-any.whl", hash = "sha256:92cfa54253d35417184c297ad25bfd921d95f15d60a1ca75f14d4e7acd152a29", size = 322515, upload-time = "2026-02-10T01:55:22.531Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.optional-dependencies]
|
[package.optional-dependencies]
|
||||||
|
|
@ -1028,6 +1028,7 @@ dependencies = [
|
||||||
{ name = "langgraph" },
|
{ name = "langgraph" },
|
||||||
{ name = "langgraph-cli", extra = ["inmem"] },
|
{ name = "langgraph-cli", extra = ["inmem"] },
|
||||||
{ name = "langgraph-sdk" },
|
{ name = "langgraph-sdk" },
|
||||||
|
{ name = "langsmith" },
|
||||||
{ name = "markdownify" },
|
{ name = "markdownify" },
|
||||||
{ name = "pyjwt" },
|
{ name = "pyjwt" },
|
||||||
{ name = "uvicorn" },
|
{ name = "uvicorn" },
|
||||||
|
|
@ -1051,6 +1052,7 @@ requires-dist = [
|
||||||
{ name = "langgraph", specifier = ">=1.0.8" },
|
{ name = "langgraph", specifier = ">=1.0.8" },
|
||||||
{ name = "langgraph-cli", extras = ["inmem"], specifier = ">=0.4.12" },
|
{ name = "langgraph-cli", extras = ["inmem"], specifier = ">=0.4.12" },
|
||||||
{ name = "langgraph-sdk", specifier = ">=0.1.0" },
|
{ name = "langgraph-sdk", specifier = ">=0.1.0" },
|
||||||
|
{ name = "langsmith", specifier = ">=0.7.1" },
|
||||||
{ name = "markdownify", specifier = ">=1.2.2" },
|
{ name = "markdownify", specifier = ">=1.2.2" },
|
||||||
{ name = "pyjwt", specifier = ">=2.8.0" },
|
{ name = "pyjwt", specifier = ">=2.8.0" },
|
||||||
{ name = "pytest", marker = "extra == 'dev'", specifier = ">=7.0.0" },
|
{ name = "pytest", marker = "extra == 'dev'", specifier = ">=7.0.0" },
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue