on main help sign in
fix(tools): some errors need to be sent to the LLM
0ba17e8Kujtim Hoxha
internal/agent/tools/grep.go+1−1
@@ -119,7 +119,7 @@ func NewGrepTool(workingDir string) fantasy.AgentTool {
119
119
120 matches, truncated, err := searchFiles(ctx, searchPattern, searchPath, params.Include, 100)
120 matches, truncated, err := searchFiles(ctx, searchPattern, searchPath, params.Include, 100)
121 if err != nil {
121 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
123 }
123 }
124
124
125 var output strings.Builder
125 var output strings.Builder
internal/agent/tools/ls.go+3−3
@@ -54,7 +54,7 @@ func NewLsTool(permissions permission.Service, workingDir string, lsConfig confi
54 func(ctx context.Context, params LSParams, call fantasy.ToolCall) (fantasy.ToolResponse, error) {
54 func(ctx context.Context, params LSParams, call fantasy.ToolCall) (fantasy.ToolResponse, error) {
55 searchPath, err := fsext.Expand(cmp.Or(params.Path, workingDir))
55 searchPath, err := fsext.Expand(cmp.Or(params.Path, workingDir))
56 if err != nil {
56 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
58 }
58 }
59
59
60 if !filepath.IsAbs(searchPath) {
60 if !filepath.IsAbs(searchPath) {
@@ -64,12 +64,12 @@ func NewLsTool(permissions permission.Service, workingDir string, lsConfig confi
64 // Check if directory is outside working directory and request permission if needed
64 // Check if directory is outside working directory and request permission if needed
65 absWorkingDir, err := filepath.Abs(workingDir)
65 absWorkingDir, err := filepath.Abs(workingDir)
66 if err != nil {
66 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
68 }
68 }
69
69
70 absSearchPath, err := filepath.Abs(searchPath)
70 absSearchPath, err := filepath.Abs(searchPath)
71 if err != nil {
71 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
73 }
73 }
74
74
75 relPath, err := filepath.Rel(absWorkingDir, absSearchPath)
75 relPath, err := filepath.Rel(absWorkingDir, absSearchPath)