From 773efbf84f5bc426633cf7221621ce7af2120f3b Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 25 Feb 2026 11:46:49 -0500 Subject: [PATCH] fix(tools/view): perform UTF-8 validity check only if read succeeds Prior to this change the check would happen before we would know if the file read was successful. --- internal/agent/tools/view.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/agent/tools/view.go b/internal/agent/tools/view.go index 0e56a4f6866d018efabfa952b7a10dc97507656f..77e51aa8e491c685a12aac9c9cf2235cebf0126f 100644 --- a/internal/agent/tools/view.go +++ b/internal/agent/tools/view.go @@ -189,8 +189,7 @@ func NewViewTool( if err != nil { return fantasy.ToolResponse{}, fmt.Errorf("error reading file: %w", err) } - isValidUt8 := utf8.ValidString(content) - if !isValidUt8 { + if !utf8.ValidString(content) { return fantasy.NewTextErrorResponse("File content is not valid UTF-8"), nil }