fix(tools/view): perform UTF-8 validity check only if read succeeds

Christian Rocha created

Prior to this change the check would happen before we would know if the
file read was successful.

Change summary

internal/agent/tools/view.go | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

Detailed changes

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
 			}