fc93a1b55a
Oversized tool results are archived to disk and replaced in-context with a 'Full output saved to: <path>' reference. Until now the write was trusted blind: a partially-flushed host file (ENOSPC/quota races) or a lossy sandbox write (API-body truncation on payload backends) still produced the archive reference, so the model was told the full result was recoverable when bytes had silently vanished. Both persistence paths now round-trip-verify size before building the reference and fail closed to the bounded inline truncation otherwise: - _write_to_spillover: byte-count check via os.stat after write; mismatched archives are deleted and the caller falls through to inline truncation. - _write_to_sandbox: wc -c probe after the cat; heredoc-mode backends get a +1 byte tolerance (wrap_modal_stdin_heredoc appends one newline by construction), unprobeable backends stay best-effort success. Regression tests fail without the fix (verified by stashing the source change: 4 failed). E2E-verified against a temp HERMES_HOME with real file I/O including multibyte content and a simulated short write.