From 29f5df5e8a933714f201644995d16c7cc796cb7e Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 21:28:49 +0000 Subject: [PATCH] fix: improve io.ReadFull error handling for partial reads Update pkg/tools/filesystem.go to treat io.ErrUnexpectedEOF and io.EOF as normal terminal conditions during partial reads, ensuring robust detection of further content. Also modernized error checks using errors.Is. Co-authored-by: hobbyistlabs-coder <267281733+hobbyistlabs-coder@users.noreply.github.com> --- pkg/tools/filesystem.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/tools/filesystem.go b/pkg/tools/filesystem.go index 0d677ae52..0067d3edb 100644 --- a/pkg/tools/filesystem.go +++ b/pkg/tools/filesystem.go @@ -234,10 +234,11 @@ func (t *ReadFileTool) Execute(ctx context.Context, args map[string]any) *ToolRe // This avoids the false-positive TRUNCATED message on the last page. probe := make([]byte, length+1) n, err := io.ReadFull(file, probe) - // FIX: io.ReadFull returns io.ErrUnexpectedEOF for partial reads (0 < n < len), + + // io.ReadFull returns io.ErrUnexpectedEOF for partial reads (0 < n < len), // and io.EOF only when n == 0. Both are normal terminal conditions — only // other errors are genuine failures. - if err != nil && err != io.EOF && !errors.Is(err, io.ErrUnexpectedEOF) { + if err != nil && !errors.Is(err, io.EOF) && !errors.Is(err, io.ErrUnexpectedEOF) { return ErrorResult(fmt.Sprintf("failed to read file content: %v", err)) }