@@ -1564,9 +1564,9 @@ impl ChatContext {
1564
1564
Ok ( match command {
1565
1565
Command :: Ask { prompt } => {
1566
1566
// Check for a pending tool approval
1567
+ let tool_denied_without_reason = [ "n" , "N" ] . contains ( & prompt. as_str ( ) ) ;
1567
1568
if let Some ( index) = pending_tool_index {
1568
1569
let tool_use = & mut tool_uses[ index] ;
1569
-
1570
1570
let is_trust = [ "t" , "T" ] . contains ( & prompt. as_str ( ) ) ;
1571
1571
if [ "y" , "Y" ] . contains ( & prompt. as_str ( ) ) || is_trust {
1572
1572
if is_trust {
@@ -1575,6 +1575,23 @@ impl ChatContext {
1575
1575
tool_use. accepted = true ;
1576
1576
1577
1577
return Ok ( ChatState :: ExecuteTools ( tool_uses) ) ;
1578
+ // Prompt reason if no selected
1579
+ } else if tool_denied_without_reason {
1580
+ tool_use. accepted = false ;
1581
+ execute ! (
1582
+ self . output,
1583
+ style:: SetForegroundColor ( Color :: DarkGrey ) ,
1584
+ style:: Print (
1585
+ "\n Please provide a reason for denying this tool use, or otherwise continue your conversation:\n \n "
1586
+ ) ,
1587
+ style:: SetForegroundColor ( Color :: Reset ) ,
1588
+ ) ?;
1589
+
1590
+ return Ok ( ChatState :: PromptUser {
1591
+ tool_uses : Some ( tool_uses) ,
1592
+ pending_tool_index,
1593
+ skip_printing_tools : true ,
1594
+ } ) ;
1578
1595
}
1579
1596
} else if !self . pending_prompts . is_empty ( ) {
1580
1597
let prompts = self . pending_prompts . drain ( 0 ..) . collect ( ) ;
@@ -1586,7 +1603,6 @@ impl ChatContext {
1586
1603
1587
1604
// Otherwise continue with normal chat on 'n' or other responses
1588
1605
self . tool_use_status = ToolUseStatus :: Idle ;
1589
-
1590
1606
if pending_tool_index. is_some ( ) {
1591
1607
self . conversation_state . abandon_tool_use ( tool_uses, user_input) ;
1592
1608
} else {
@@ -4602,11 +4618,13 @@ mod tests {
4602
4618
"/tools untrust fs_write" . to_string( ) ,
4603
4619
"create a file" . to_string( ) , // prompt again due to untrust
4604
4620
"n" . to_string( ) , // cancel
4621
+ "no reason" . to_string( ) , // dummy reason
4605
4622
"/tools trust fs_write" . to_string( ) ,
4606
4623
"create a file" . to_string( ) , // again without prompting due to '/tools trust'
4607
4624
"/tools reset" . to_string( ) ,
4608
4625
"create a file" . to_string( ) , // prompt again due to reset
4609
4626
"n" . to_string( ) , // cancel
4627
+ "no reason" . to_string( ) , // dummy reason
4610
4628
"exit" . to_string( ) ,
4611
4629
] ) ,
4612
4630
true ,
0 commit comments