The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(environments): cover Vercel stdin staging instead of the local contract
kshitijk4poor7d29687ae69c
diff --git a/tests/tools/test_file_write_surrogate_roundtrip.py b/tests/tools/test_file_write_surrogate_roundtrip.pyindex 0df0f57e86b..f94da8e8f74 100644--- a/tests/tools/test_file_write_surrogate_roundtrip.py+++ b/tests/tools/test_file_write_surrogate_roundtrip.py@@ -82,39 +82,6 @@ class TestPipeStdinSurrogates:assert proc._hermes_stdin_errors == []-class _PayloadLocalEnvironment(LocalEnvironment):- """Exercise BaseEnvironment's payload-mode contract with a real local pipe."""-- _stdin_mode = "payload"-- def __init__(self, cwd: str):- self.spawn_commands: list[str] = []- super().__init__(cwd=cwd, timeout=15)-- def _run_bash(self, cmd_string, *, login=False, timeout=120, stdin_data=None):- self.spawn_commands.append(cmd_string)- return super()._run_bash(- cmd_string, login=login, timeout=timeout, stdin_data=stdin_data- )--[email protected]("posix")-def test_payload_mode_write_is_byte_exact_beyond_argv_limit(tmp_path):- """Payload-mode stdin stays out of bash argv and preserves arbitrary bytes."""- env = _PayloadLocalEnvironment(str(tmp_path))- ops = ShellFileOperations(env, cwd=str(tmp_path))- raw = (b"A" * (160 * 1024)) + b"\x00\xff\xfeTAIL"- content = raw.decode("utf-8", "surrogateescape")- target = tmp_path / "large-binary-like.bin"-- result = ops.write_file(str(target), content)-- assert result.error is None and result.verified is True- assert result.bytes_written == len(raw)- assert target.read_bytes() == raw- assert max(len(command.encode("utf-8")) for command in env.spawn_commands) < 128 * 1024--@pytest.fixturedef env(tmp_path):"""A real LocalEnvironment rooted in a temp directory."""diff --git a/tests/tools/test_modal_bulk_upload.py b/tests/tools/test_modal_bulk_upload.pyindex f349219d207..caf46173429 100644--- a/tests/tools/test_modal_bulk_upload.py+++ b/tests/tools/test_modal_bulk_upload.py@@ -168,7 +168,6 @@ class TestModalCommandStdin:handle = env._run_bash("cat > /tmp/payload.txt", stdin_data=payload)assert handle.wait(timeout=2) == 0- assert modal_env.ModalEnvironment._stdin_mode == "payload"assert b"".join(stdin_mock._written_chunks) == expectedassert len(exec_calls) == 1assert payload not in " ".join(str(part) for part in exec_calls[0])diff --git a/tests/tools/test_vercel_sandbox_environment.py b/tests/tools/test_vercel_sandbox_environment.pyindex 4b2694ce8b5..5037ccf60dc 100644--- a/tests/tools/test_vercel_sandbox_environment.py+++ b/tests/tools/test_vercel_sandbox_environment.py@@ -524,6 +524,25 @@ class TestExecute:assert kwargs["cwd"] == "/vercel/sandbox"+ def test_payload_stdin_is_staged_byte_exact_not_in_argv(self, make_env):+ env = make_env()+ sandbox = env._sandbox+ raw = (b"A" * (160 * 1024)) + b"\x00\xff\xfeTAIL"+ writes_before = len(sandbox.write_files_calls)++ handle = env._run_bash("cat > /tmp/out", stdin_data=raw.decode("utf-8", "surrogateescape"))++ assert handle.wait(timeout=2) == 0+ (staged,) = sandbox.write_files_calls[writes_before]+ assert staged["content"] == raw+ assert staged["mode"] == 0o600+ cmd, args, _ = sandbox.run_command_calls[-1]+ assert cmd == "bash" and args[0] == "-c"+ assert args[1].startswith(f"exec 0< {staged['path']} || exit $?\n")+ assert args[1].endswith("\ncat > /tmp/out")+ assert "AAAAAAAAAAAAAAAA" not in " ".join(args)++class TestSnapshotPersistence:def test_create_restores_from_saved_snapshot(self, make_env, vercel_module, vercel_sdk, monkeypatch, tmp_path