1
1
use super :: * ;
2
2
use acp_thread:: { AgentConnection , AgentModelGroupName , AgentModelList , UserMessageId } ;
3
- use action_log:: ActionLog ;
4
3
use agent_client_protocol:: { self as acp} ;
5
4
use agent_settings:: AgentProfileId ;
6
5
use anyhow:: Result ;
@@ -224,7 +223,7 @@ async fn test_prompt_caching(cx: &mut TestAppContext) {
224
223
225
224
let tool_use = LanguageModelToolUse {
226
225
id : "tool_1" . into ( ) ,
227
- name : EchoTool . name ( ) . into ( ) ,
226
+ name : EchoTool :: name ( ) . into ( ) ,
228
227
raw_input : json ! ( { "text" : "test" } ) . to_string ( ) ,
229
228
input : json ! ( { "text" : "test" } ) ,
230
229
is_input_complete : true ,
@@ -237,7 +236,7 @@ async fn test_prompt_caching(cx: &mut TestAppContext) {
237
236
let completion = fake_model. pending_completions ( ) . pop ( ) . unwrap ( ) ;
238
237
let tool_result = LanguageModelToolResult {
239
238
tool_use_id : "tool_1" . into ( ) ,
240
- tool_name : EchoTool . name ( ) . into ( ) ,
239
+ tool_name : EchoTool :: name ( ) . into ( ) ,
241
240
is_error : false ,
242
241
content : "test" . into ( ) ,
243
242
output : Some ( "test" . into ( ) ) ,
@@ -307,7 +306,7 @@ async fn test_basic_tool_calls(cx: &mut TestAppContext) {
307
306
// Test a tool calls that's likely to complete *after* streaming stops.
308
307
let events = thread
309
308
. update ( cx, |thread, cx| {
310
- thread. remove_tool ( & AgentTool :: name ( & EchoTool ) ) ;
309
+ thread. remove_tool ( & EchoTool :: name ( ) ) ;
311
310
thread. add_tool ( DelayTool ) ;
312
311
thread. send (
313
312
UserMessageId :: new ( ) ,
@@ -411,7 +410,7 @@ async fn test_tool_authorization(cx: &mut TestAppContext) {
411
410
fake_model. send_last_completion_stream_event ( LanguageModelCompletionEvent :: ToolUse (
412
411
LanguageModelToolUse {
413
412
id : "tool_id_1" . into ( ) ,
414
- name : ToolRequiringPermission . name ( ) . into ( ) ,
413
+ name : ToolRequiringPermission :: name ( ) . into ( ) ,
415
414
raw_input : "{}" . into ( ) ,
416
415
input : json ! ( { } ) ,
417
416
is_input_complete : true ,
@@ -420,7 +419,7 @@ async fn test_tool_authorization(cx: &mut TestAppContext) {
420
419
fake_model. send_last_completion_stream_event ( LanguageModelCompletionEvent :: ToolUse (
421
420
LanguageModelToolUse {
422
421
id : "tool_id_2" . into ( ) ,
423
- name : ToolRequiringPermission . name ( ) . into ( ) ,
422
+ name : ToolRequiringPermission :: name ( ) . into ( ) ,
424
423
raw_input : "{}" . into ( ) ,
425
424
input : json ! ( { } ) ,
426
425
is_input_complete : true ,
@@ -451,14 +450,14 @@ async fn test_tool_authorization(cx: &mut TestAppContext) {
451
450
vec![
452
451
language_model:: MessageContent :: ToolResult ( LanguageModelToolResult {
453
452
tool_use_id: tool_call_auth_1. tool_call. id. 0 . to_string( ) . into( ) ,
454
- tool_name: ToolRequiringPermission . name( ) . into( ) ,
453
+ tool_name: ToolRequiringPermission :: name( ) . into( ) ,
455
454
is_error: false ,
456
455
content: "Allowed" . into( ) ,
457
456
output: Some ( "Allowed" . into( ) )
458
457
} ) ,
459
458
language_model:: MessageContent :: ToolResult ( LanguageModelToolResult {
460
459
tool_use_id: tool_call_auth_2. tool_call. id. 0 . to_string( ) . into( ) ,
461
- tool_name: ToolRequiringPermission . name( ) . into( ) ,
460
+ tool_name: ToolRequiringPermission :: name( ) . into( ) ,
462
461
is_error: true ,
463
462
content: "Permission to run tool denied by user" . into( ) ,
464
463
output: None
@@ -470,7 +469,7 @@ async fn test_tool_authorization(cx: &mut TestAppContext) {
470
469
fake_model. send_last_completion_stream_event ( LanguageModelCompletionEvent :: ToolUse (
471
470
LanguageModelToolUse {
472
471
id : "tool_id_3" . into ( ) ,
473
- name : ToolRequiringPermission . name ( ) . into ( ) ,
472
+ name : ToolRequiringPermission :: name ( ) . into ( ) ,
474
473
raw_input : "{}" . into ( ) ,
475
474
input : json ! ( { } ) ,
476
475
is_input_complete : true ,
@@ -492,7 +491,7 @@ async fn test_tool_authorization(cx: &mut TestAppContext) {
492
491
vec![ language_model:: MessageContent :: ToolResult (
493
492
LanguageModelToolResult {
494
493
tool_use_id: tool_call_auth_3. tool_call. id. 0 . to_string( ) . into( ) ,
495
- tool_name: ToolRequiringPermission . name( ) . into( ) ,
494
+ tool_name: ToolRequiringPermission :: name( ) . into( ) ,
496
495
is_error: false ,
497
496
content: "Allowed" . into( ) ,
498
497
output: Some ( "Allowed" . into( ) )
@@ -504,7 +503,7 @@ async fn test_tool_authorization(cx: &mut TestAppContext) {
504
503
fake_model. send_last_completion_stream_event ( LanguageModelCompletionEvent :: ToolUse (
505
504
LanguageModelToolUse {
506
505
id : "tool_id_4" . into ( ) ,
507
- name : ToolRequiringPermission . name ( ) . into ( ) ,
506
+ name : ToolRequiringPermission :: name ( ) . into ( ) ,
508
507
raw_input : "{}" . into ( ) ,
509
508
input : json ! ( { } ) ,
510
509
is_input_complete : true ,
@@ -519,7 +518,7 @@ async fn test_tool_authorization(cx: &mut TestAppContext) {
519
518
vec![ language_model:: MessageContent :: ToolResult (
520
519
LanguageModelToolResult {
521
520
tool_use_id: "tool_id_4" . into( ) ,
522
- tool_name: ToolRequiringPermission . name( ) . into( ) ,
521
+ tool_name: ToolRequiringPermission :: name( ) . into( ) ,
523
522
is_error: false ,
524
523
content: "Allowed" . into( ) ,
525
524
output: Some ( "Allowed" . into( ) )
@@ -571,7 +570,7 @@ async fn test_resume_after_tool_use_limit(cx: &mut TestAppContext) {
571
570
cx. run_until_parked ( ) ;
572
571
let tool_use = LanguageModelToolUse {
573
572
id : "tool_id_1" . into ( ) ,
574
- name : EchoTool . name ( ) . into ( ) ,
573
+ name : EchoTool :: name ( ) . into ( ) ,
575
574
raw_input : "{}" . into ( ) ,
576
575
input : serde_json:: to_value ( & EchoToolInput { text : "def" . into ( ) } ) . unwrap ( ) ,
577
576
is_input_complete : true ,
@@ -584,7 +583,7 @@ async fn test_resume_after_tool_use_limit(cx: &mut TestAppContext) {
584
583
let completion = fake_model. pending_completions ( ) . pop ( ) . unwrap ( ) ;
585
584
let tool_result = LanguageModelToolResult {
586
585
tool_use_id : "tool_id_1" . into ( ) ,
587
- tool_name : EchoTool . name ( ) . into ( ) ,
586
+ tool_name : EchoTool :: name ( ) . into ( ) ,
588
587
is_error : false ,
589
588
content : "def" . into ( ) ,
590
589
output : Some ( "def" . into ( ) ) ,
@@ -690,14 +689,14 @@ async fn test_send_after_tool_use_limit(cx: &mut TestAppContext) {
690
689
691
690
let tool_use = LanguageModelToolUse {
692
691
id : "tool_id_1" . into ( ) ,
693
- name : EchoTool . name ( ) . into ( ) ,
692
+ name : EchoTool :: name ( ) . into ( ) ,
694
693
raw_input : "{}" . into ( ) ,
695
694
input : serde_json:: to_value ( & EchoToolInput { text : "def" . into ( ) } ) . unwrap ( ) ,
696
695
is_input_complete : true ,
697
696
} ;
698
697
let tool_result = LanguageModelToolResult {
699
698
tool_use_id : "tool_id_1" . into ( ) ,
700
- tool_name : EchoTool . name ( ) . into ( ) ,
699
+ tool_name : EchoTool :: name ( ) . into ( ) ,
701
700
is_error : false ,
702
701
content : "def" . into ( ) ,
703
702
output : Some ( "def" . into ( ) ) ,
@@ -874,14 +873,14 @@ async fn test_profiles(cx: &mut TestAppContext) {
874
873
"test-1" : {
875
874
"name" : "Test Profile 1" ,
876
875
"tools" : {
877
- EchoTool . name( ) : true ,
878
- DelayTool . name( ) : true ,
876
+ EchoTool :: name( ) : true ,
877
+ DelayTool :: name( ) : true ,
879
878
}
880
879
} ,
881
880
"test-2" : {
882
881
"name" : "Test Profile 2" ,
883
882
"tools" : {
884
- InfiniteTool . name( ) : true ,
883
+ InfiniteTool :: name( ) : true ,
885
884
}
886
885
}
887
886
}
@@ -910,7 +909,7 @@ async fn test_profiles(cx: &mut TestAppContext) {
910
909
. iter ( )
911
910
. map ( |tool| tool. name . clone ( ) )
912
911
. collect ( ) ;
913
- assert_eq ! ( tool_names, vec![ DelayTool . name( ) , EchoTool . name( ) ] ) ;
912
+ assert_eq ! ( tool_names, vec![ DelayTool :: name( ) , EchoTool :: name( ) ] ) ;
914
913
fake_model. end_last_completion_stream ( ) ;
915
914
916
915
// Switch to test-2 profile, and verify that it has only the infinite tool.
@@ -929,7 +928,7 @@ async fn test_profiles(cx: &mut TestAppContext) {
929
928
. iter ( )
930
929
. map ( |tool| tool. name . clone ( ) )
931
930
. collect ( ) ;
932
- assert_eq ! ( tool_names, vec![ InfiniteTool . name( ) ] ) ;
931
+ assert_eq ! ( tool_names, vec![ InfiniteTool :: name( ) ] ) ;
933
932
}
934
933
935
934
#[ gpui:: test]
@@ -1552,7 +1551,7 @@ async fn test_tool_updates_to_completion(cx: &mut TestAppContext) {
1552
1551
fake_model. send_last_completion_stream_event ( LanguageModelCompletionEvent :: ToolUse (
1553
1552
LanguageModelToolUse {
1554
1553
id : "1" . into ( ) ,
1555
- name : ThinkingTool . name ( ) . into ( ) ,
1554
+ name : ThinkingTool :: name ( ) . into ( ) ,
1556
1555
raw_input : input. to_string ( ) ,
1557
1556
input,
1558
1557
is_input_complete : false ,
@@ -1840,11 +1839,11 @@ async fn setup(cx: &mut TestAppContext, model: TestModel) -> ThreadTest {
1840
1839
"test-profile" : {
1841
1840
"name" : "Test Profile" ,
1842
1841
"tools" : {
1843
- EchoTool . name( ) : true ,
1844
- DelayTool . name( ) : true ,
1845
- WordListTool . name( ) : true ,
1846
- ToolRequiringPermission . name( ) : true ,
1847
- InfiniteTool . name( ) : true ,
1842
+ EchoTool :: name( ) : true ,
1843
+ DelayTool :: name( ) : true ,
1844
+ WordListTool :: name( ) : true ,
1845
+ ToolRequiringPermission :: name( ) : true ,
1846
+ InfiniteTool :: name( ) : true ,
1848
1847
}
1849
1848
}
1850
1849
}
@@ -1903,13 +1902,11 @@ async fn setup(cx: &mut TestAppContext, model: TestModel) -> ThreadTest {
1903
1902
let project_context = cx. new ( |_cx| ProjectContext :: default ( ) ) ;
1904
1903
let context_server_registry =
1905
1904
cx. new ( |cx| ContextServerRegistry :: new ( project. read ( cx) . context_server_store ( ) , cx) ) ;
1906
- let action_log = cx. new ( |_| ActionLog :: new ( project. clone ( ) ) ) ;
1907
1905
let thread = cx. new ( |cx| {
1908
1906
Thread :: new (
1909
1907
project,
1910
1908
project_context. clone ( ) ,
1911
1909
context_server_registry,
1912
- action_log,
1913
1910
templates,
1914
1911
Some ( model. clone ( ) ) ,
1915
1912
cx,
0 commit comments