on main help sign in
fix(tools): some errors need to be sent to the LLM
commit0ba17e876fa32624d027006a6ffc8d930b30d12a authorKujtim Hoxha <kujtimii.h@gmail.com> dateMon 20 Oct 2025, 11:09 (1 year ago) parent6e94603
2 files changed+4−4
internal/agent/tools/grep.go+1−1 internal/agent/tools/ls.go+3−3
internal/agent/tools/grep.go+1−1
@@ -119,7 +119,7 @@ func NewGrepTool(workingDir string) fantasy.AgentTool {
119119
120120 matches, truncated, err := searchFiles(ctx, searchPattern, searchPath, params.Include, 100)
121121 if err != nil {
122− return fantasy.ToolResponse{}, fmt.Errorf("error searching files: %w", err)
122+ return fantasy.NewTextErrorResponse(fmt.Sprintf("error searching files: %v", err)), nil
123123 }
124124
125125 var output strings.Builder
internal/agent/tools/ls.go+3−3
@@ -54,7 +54,7 @@ func NewLsTool(permissions permission.Service, workingDir string, lsConfig confi
5454 func(ctx context.Context, params LSParams, call fantasy.ToolCall) (fantasy.ToolResponse, error) {
5555 searchPath, err := fsext.Expand(cmp.Or(params.Path, workingDir))
5656 if err != nil {
57− return fantasy.ToolResponse{}, fmt.Errorf("error expanding path: %w", err)
57+ return fantasy.NewTextErrorResponse(fmt.Sprintf("error expanding path: %v", err)), nil
5858 }
5959
6060 if !filepath.IsAbs(searchPath) {
@@ -64,12 +64,12 @@ func NewLsTool(permissions permission.Service, workingDir string, lsConfig confi
6464 // Check if directory is outside working directory and request permission if needed
6565 absWorkingDir, err := filepath.Abs(workingDir)
6666 if err != nil {
67− return fantasy.ToolResponse{}, fmt.Errorf("error resolving working directory: %w", err)
67+ return fantasy.NewTextErrorResponse(fmt.Sprintf("error resolving working directory: %v", err)), nil
6868 }
6969
7070 absSearchPath, err := filepath.Abs(searchPath)
7171 if err != nil {
72− return fantasy.ToolResponse{}, fmt.Errorf("error resolving search path: %w", err)
72+ return fantasy.NewTextErrorResponse(fmt.Sprintf("error resolving search path: %v", err)), nil
7373 }
7474
7575 relPath, err := filepath.Rel(absWorkingDir, absSearchPath)