on main help sign in
fix(tools): lowercase all remaining error messages for Go convention

Standardize all NewTextErrorResponse messages across fetch.go, download.go, web_fetch.go, mcp-tools.go, web_search.go, and sourcegraph.go to start with lowercase, matching Go error message conventions and the already-fixed edit/view/write tools.

commit9af07ec821d2af1ba609d3e8ba02683a6095db56 authoriko <mail@iko.soy> dateThu 9 Jul 2026, 03:57 (3 months ago) parent2679ea6
6 files changed+24−24
internal/agent/tools/download.go+3−3 internal/agent/tools/fetch.go+11−11 internal/agent/tools/mcp-tools.go+1−1 internal/agent/tools/sourcegraph.go+4−4 internal/agent/tools/web_fetch.go+4−4 internal/agent/tools/web_search.go+1−1
internal/agent/tools/download.go+3−3
@@ -67,7 +67,7 @@ func NewDownloadTool(permissions permission.Service, workingDir string, client *
6767 downloadDescription(),
6868 func(ctx context.Context, params DownloadParams, call fantasy.ToolCall) (fantasy.ToolResponse, error) {
6969 if params.URL == "" {
70− return fantasy.NewTextErrorResponse("URL parameter is required"), nil
70+ return fantasy.NewTextErrorResponse("url parameter is required"), nil
7171 }
7272
7373 if params.FilePath == "" {
@@ -75,7 +75,7 @@ func NewDownloadTool(permissions permission.Service, workingDir string, client *
7575 }
7676
7777 if !strings.HasPrefix(params.URL, "http://") && !strings.HasPrefix(params.URL, "https://") {
78− return fantasy.NewTextErrorResponse("URL must start with http:// or https://"), nil
78+ return fantasy.NewTextErrorResponse("url must start with http:// or https://"), nil
7979 }
8080
8181 filePath := filepathext.SmartJoin(workingDir, params.FilePath)
@@ -131,7 +131,7 @@ func NewDownloadTool(permissions permission.Service, workingDir string, client *
131131 defer resp.Body.Close()
132132
133133 if resp.StatusCode != http.StatusOK {
134− return fantasy.NewTextErrorResponse(fmt.Sprintf("Request failed with status code: %d", resp.StatusCode)), nil
134+ return fantasy.NewTextErrorResponse(fmt.Sprintf("request failed with status code: %d", resp.StatusCode)), nil
135135 }
136136
137137 // Create parent directories if they don't exist
internal/agent/tools/fetch.go+11−11
@@ -60,16 +60,16 @@ func NewFetchTool(permissions permission.Service, workingDir string, client *htt
6060 fetchDescription(),
6161 func(ctx context.Context, params FetchParams, call fantasy.ToolCall) (fantasy.ToolResponse, error) {
6262 if params.URL == "" {
63− return fantasy.NewTextErrorResponse("URL parameter is required"), nil
63+ return fantasy.NewTextErrorResponse("url parameter is required"), nil
6464 }
6565
6666 format := strings.ToLower(params.Format)
6767 if format != "text" && format != "markdown" && format != "html" {
68− return fantasy.NewTextErrorResponse("Format must be one of: text, markdown, html"), nil
68+ return fantasy.NewTextErrorResponse("format must be one of: text, markdown, html"), nil
6969 }
7070
7171 if !strings.HasPrefix(params.URL, "http://") && !strings.HasPrefix(params.URL, "https://") {
72− return fantasy.NewTextErrorResponse("URL must start with http:// or https://"), nil
72+ return fantasy.NewTextErrorResponse("url must start with http:// or https://"), nil
7373 }
7474
7575 sessionID := GetSessionFromContext(ctx)
@@ -124,19 +124,19 @@ func NewFetchTool(permissions permission.Service, workingDir string, client *htt
124124 defer resp.Body.Close()
125125
126126 if resp.StatusCode != http.StatusOK {
127− return fantasy.NewTextErrorResponse(fmt.Sprintf("Request failed with status code: %d", resp.StatusCode)), nil
127+ return fantasy.NewTextErrorResponse(fmt.Sprintf("request failed with status code: %d", resp.StatusCode)), nil
128128 }
129129
130130 body, err := io.ReadAll(io.LimitReader(resp.Body, MaxFetchSize))
131131 if err != nil {
132− return fantasy.NewTextErrorResponse("Failed to read response body: " + err.Error()), nil
132+ return fantasy.NewTextErrorResponse("failed to read response body: " + err.Error()), nil
133133 }
134134
135135 content := string(body)
136136
137137 validUTF8 := utf8.ValidString(content)
138138 if !validUTF8 {
139− return fantasy.NewTextErrorResponse("Response content is not valid UTF-8"), nil
139+ return fantasy.NewTextErrorResponse("response content is not valid UTF-8"), nil
140140 }
141141 contentType := resp.Header.Get("Content-Type")
142142
@@ -145,7 +145,7 @@ func NewFetchTool(permissions permission.Service, workingDir string, client *htt
145145 if strings.Contains(contentType, "text/html") {
146146 text, err := extractTextFromHTML(content)
147147 if err != nil {
148− return fantasy.NewTextErrorResponse("Failed to extract text from HTML: " + err.Error()), nil
148+ return fantasy.NewTextErrorResponse("failed to extract text from HTML: " + err.Error()), nil
149149 }
150150 content = text
151151 }
@@ -154,7 +154,7 @@ func NewFetchTool(permissions permission.Service, workingDir string, client *htt
154154 if strings.Contains(contentType, "text/html") {
155155 markdown, err := convertHTMLToMarkdown(content)
156156 if err != nil {
157− return fantasy.NewTextErrorResponse("Failed to convert HTML to Markdown: " + err.Error()), nil
157+ return fantasy.NewTextErrorResponse("failed to convert HTML to Markdown: " + err.Error()), nil
158158 }
159159 content = markdown
160160 }
@@ -166,14 +166,14 @@ func NewFetchTool(permissions permission.Service, workingDir string, client *htt
166166 if strings.Contains(contentType, "text/html") {
167167 doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
168168 if err != nil {
169− return fantasy.NewTextErrorResponse("Failed to parse HTML: " + err.Error()), nil
169+ return fantasy.NewTextErrorResponse("failed to parse HTML: " + err.Error()), nil
170170 }
171171 body, err := doc.Find("body").Html()
172172 if err != nil {
173− return fantasy.NewTextErrorResponse("Failed to extract body from HTML: " + err.Error()), nil
173+ return fantasy.NewTextErrorResponse("failed to extract body from HTML: " + err.Error()), nil
174174 }
175175 if body == "" {
176− return fantasy.NewTextErrorResponse("No body content found in HTML"), nil
176+ return fantasy.NewTextErrorResponse("no body content found in HTML"), nil
177177 }
178178 content = "<html>\n<body>\n" + body + "\n</body>\n</html>"
179179 }
internal/agent/tools/mcp-tools.go+1−1
@@ -134,7 +134,7 @@ func (m *Tool) Run(ctx context.Context, params fantasy.ToolCall) (fantasy.ToolRe
134134 case "image", "media":
135135 if !GetSupportsImagesFromContext(ctx) {
136136 modelName := GetModelNameFromContext(ctx)
137− return fantasy.NewTextErrorResponse(fmt.Sprintf("This model (%s) does not support image data.", modelName)), nil
137+ return fantasy.NewTextErrorResponse(fmt.Sprintf("this model (%s) does not support image data.", modelName)), nil
138138 }
139139
140140 var response fantasy.ToolResponse
internal/agent/tools/sourcegraph.go+4−4
@@ -64,7 +64,7 @@ func NewSourcegraphTool(client *http.Client) fantasy.AgentTool {
6464 sourcegraphDescription(),
6565 func(ctx context.Context, params SourcegraphParams, call fantasy.ToolCall) (fantasy.ToolResponse, error) {
6666 if params.Query == "" {
67− return fantasy.NewTextErrorResponse("Query parameter is required"), nil
67+ return fantasy.NewTextErrorResponse("query parameter is required"), nil
6868 }
6969
7070 if params.Count <= 0 {
@@ -129,10 +129,10 @@ func NewSourcegraphTool(client *http.Client) fantasy.AgentTool {
129129 if resp.StatusCode != http.StatusOK {
130130 body, _ := io.ReadAll(resp.Body)
131131 if len(body) > 0 {
132− return fantasy.NewTextErrorResponse(fmt.Sprintf("Request failed with status code: %d, response: %s", resp.StatusCode, string(body))), nil
132+ return fantasy.NewTextErrorResponse(fmt.Sprintf("request failed with status code: %d, response: %s", resp.StatusCode, string(body))), nil
133133 }
134134
135− return fantasy.NewTextErrorResponse(fmt.Sprintf("Request failed with status code: %d", resp.StatusCode)), nil
135+ return fantasy.NewTextErrorResponse(fmt.Sprintf("request failed with status code: %d", resp.StatusCode)), nil
136136 }
137137 body, err := io.ReadAll(resp.Body)
138138 if err != nil {
@@ -146,7 +146,7 @@ func NewSourcegraphTool(client *http.Client) fantasy.AgentTool {
146146
147147 formattedResults, err := formatSourcegraphResults(result, params.ContextWindow)
148148 if err != nil {
149− return fantasy.NewTextErrorResponse("Failed to format results: " + err.Error()), nil
149+ return fantasy.NewTextErrorResponse("failed to format results: " + err.Error()), nil
150150 }
151151
152152 return fantasy.NewTextResponse(formattedResults), nil
internal/agent/tools/web_fetch.go+4−4
@@ -45,7 +45,7 @@ func NewWebFetchTool(workingDir string, client *http.Client) fantasy.AgentTool {
4545
4646 content, err := FetchURLAndConvert(ctx, client, params.URL)
4747 if err != nil {
48− return fantasy.NewTextErrorResponse(fmt.Sprintf("Failed to fetch URL: %s", err)), nil
48+ return fantasy.NewTextErrorResponse(fmt.Sprintf("failed to fetch URL: %s", err)), nil
4949 }
5050
5151 hasLargeContent := len(content) > LargeContentThreshold
@@ -54,16 +54,16 @@ func NewWebFetchTool(workingDir string, client *http.Client) fantasy.AgentTool {
5454 if hasLargeContent {
5555 tempFile, err := os.CreateTemp(workingDir, "page-*.md")
5656 if err != nil {
57− return fantasy.NewTextErrorResponse(fmt.Sprintf("Failed to create temporary file: %s", err)), nil
57+ return fantasy.NewTextErrorResponse(fmt.Sprintf("failed to create temporary file: %s", err)), nil
5858 }
5959 tempFilePath := tempFile.Name()
6060
6161 if _, err := tempFile.WriteString(content); err != nil {
6262 _ = tempFile.Close() // Best effort close
63− return fantasy.NewTextErrorResponse(fmt.Sprintf("Failed to write content to file: %s", err)), nil
63+ return fantasy.NewTextErrorResponse(fmt.Sprintf("failed to write content to file: %s", err)), nil
6464 }
6565 if err := tempFile.Close(); err != nil {
66− return fantasy.NewTextErrorResponse(fmt.Sprintf("Failed to close temporary file: %s", err)), nil
66+ return fantasy.NewTextErrorResponse(fmt.Sprintf("failed to close temporary file: %s", err)), nil
6767 }
6868
6969 fmt.Fprintf(&result, "Fetched content from %s (large page)\n\n", params.URL)
internal/agent/tools/web_search.go+1−1
@@ -53,7 +53,7 @@ func NewWebSearchTool(client *http.Client) fantasy.AgentTool {
5353 results, err := searchDuckDuckGo(ctx, client, params.Query, maxResults)
5454 slog.Debug("Web search completed", "query", params.Query, "results", len(results), "err", err)
5555 if err != nil {
56− return fantasy.NewTextErrorResponse("Failed to search: " + err.Error()), nil
56+ return fantasy.NewTextErrorResponse("failed to search: " + err.Error()), nil
5757 }
5858
5959 return fantasy.NewTextResponse(formatSearchResults(results)), nil