on main help sign in
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.

commit773efbf84f5bc426633cf7221621ce7af2120f3b authorChristian Rocha <christian@rocha.is> dateWed 25 Feb 2026, 11:46 (8 months ago) parent42aee6d
1 file changed+1−2
internal/agent/tools/view.go+1−2
internal/agent/tools/view.go+1−2
@@ -189,8 +189,7 @@ func NewViewTool(
189189 if err != nil {
190190 return fantasy.ToolResponse{}, fmt.Errorf("error reading file: %w", err)
191191 }
192− isValidUt8 := utf8.ValidString(content)
193− if !isValidUt8 {
192+ if !utf8.ValidString(content) {
194193 return fantasy.NewTextErrorResponse("File content is not valid UTF-8"), nil
195194 }
196195