Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.

Commit 9ae05fe

Browse files
committed
handle errros correctly in the bash tool
1 parent 80cd75c commit 9ae05fe

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

internal/llm/tools/bash.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,14 @@ func (b *bashTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error)
273273
},
274274
)
275275
if !p {
276-
return NewTextErrorResponse("permission denied"), nil
276+
return ToolResponse{}, permission.ErrorPermissionDenied
277277
}
278278
}
279279
startTime := time.Now()
280280
shell := shell.GetPersistentShell(config.WorkingDirectory())
281281
stdout, stderr, exitCode, interrupted, err := shell.Exec(ctx, params.Command, params.Timeout)
282282
if err != nil {
283-
return NewTextErrorResponse(fmt.Sprintf("error executing command: %s", err)), nil
283+
return ToolResponse{}, fmt.Errorf("error executing command: %w", err)
284284
}
285285
took := time.Since(startTime).Milliseconds()
286286

internal/permission/permission.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
package permission
22

33
import (
4+
"errors"
45
"sync"
56
"time"
67

78
"github.com/google/uuid"
89
"github.com/kujtimiihoxha/termai/internal/pubsub"
910
)
1011

12+
var ErrorPermissionDenied = errors.New("permission denied")
13+
1114
type CreatePermissionRequest struct {
1215
ToolName string `json:"tool_name"`
1316
Description string `json:"description"`
1417
Action string `json:"action"`
1518
Params any `json:"params"`
1619
Path string `json:"path"`
1720
}
21+
1822
type PermissionRequest struct {
1923
ID string `json:"id"`
2024
SessionID string `json:"session_id"`

0 commit comments

Comments
 (0)