@@ -59,14 +59,16 @@ func (e *ElicitationError) Error() string {
5959const (
6060 ResumeTypeApprove ResumeType = "approve"
6161 ResumeTypeApproveSession ResumeType = "approve-session"
62+ ResumeTypeApproveTool ResumeType = "approve-tool"
6263 ResumeTypeReject ResumeType = "reject"
6364)
6465
6566// ResumeRequest carries the user's confirmation decision along with an optional
6667// reason (used when rejecting a tool call to help the model understand why).
6768type ResumeRequest struct {
68- Type ResumeType
69- Reason string // Optional; primarily used with ResumeTypeReject
69+ Type ResumeType
70+ Reason string // Optional; primarily used with ResumeTypeReject
71+ ToolName string // Optional; used with ResumeTypeApproveTool to specify which tool to always allow
7072}
7173
7274// ResumeApprove creates a ResumeRequest to approve a single tool call.
@@ -79,6 +81,11 @@ func ResumeApproveSession() ResumeRequest {
7981 return ResumeRequest {Type : ResumeTypeApproveSession }
8082}
8183
84+ // ResumeApproveTool creates a ResumeRequest to always approve a specific tool for the session.
85+ func ResumeApproveTool (toolName string ) ResumeRequest {
86+ return ResumeRequest {Type : ResumeTypeApproveTool , ToolName : toolName }
87+ }
88+
8289// ResumeReject creates a ResumeRequest to reject a tool call with an optional reason.
8390func ResumeReject (reason string ) ResumeRequest {
8491 return ResumeRequest {Type : ResumeTypeReject , Reason : reason }
@@ -1432,6 +1439,20 @@ func (r *LocalRuntime) executeWithApproval(
14321439 slog .Debug ("Resume signal received, approving session" , "tool" , toolCall .Function .Name , "session_id" , sess .ID )
14331440 sess .ToolsApproved = true
14341441 runTool ()
1442+ case ResumeTypeApproveTool :
1443+ // Add the tool to session's allow list for future auto-approval
1444+ approvedTool := req .ToolName
1445+ if approvedTool == "" {
1446+ approvedTool = toolName
1447+ }
1448+ if sess .Permissions == nil {
1449+ sess .Permissions = & session.PermissionsConfig {}
1450+ }
1451+ if ! slices .Contains (sess .Permissions .Allow , approvedTool ) {
1452+ sess .Permissions .Allow = append (sess .Permissions .Allow , approvedTool )
1453+ }
1454+ slog .Debug ("Resume signal received, approving tool permanently" , "tool" , approvedTool , "session_id" , sess .ID )
1455+ runTool ()
14351456 case ResumeTypeReject :
14361457 slog .Debug ("Resume signal received, rejecting tool" , "tool" , toolCall .Function .Name , "session_id" , sess .ID , "reason" , req .Reason )
14371458 rejectMsg := "The user rejected the tool call."
0 commit comments