11use crate :: acp_fs:: AcpFsCommand ;
22use crate :: acp_history:: AcpHistoryManager ;
3- use crate :: utils:: relative_to_current_dir;
43use agent_client_protocol:: { self as acp, Agent as _, Client } ;
54use agent_client_protocol_schema:: { ProtocolVersion , SessionId } ;
65use anyhow:: { Context , Result , anyhow} ;
@@ -310,13 +309,11 @@ impl Client for AcpClientImpl {
310309 serde_json:: json!( { } )
311310 } ;
312311
313- // Extract locations from tool call update (use relative path if possible)
312+ // Keep ACP locations absolute to match the protocol and avoid path identity mismatches.
314313 let locations = tool_call_update. fields . locations . as_ref ( ) . map ( |locs| {
315314 locs. iter ( )
316315 . map ( |loc| AcpLocation {
317- path : relative_to_current_dir ( & loc. path )
318- . map ( |p| p. to_string_lossy ( ) . to_string ( ) )
319- . unwrap_or_else ( || loc. path . to_string_lossy ( ) . to_string ( ) ) ,
316+ path : loc. path . to_string_lossy ( ) . to_string ( ) ,
320317 line : loc. line ,
321318 } )
322319 . collect ( )
@@ -462,7 +459,10 @@ impl Client for AcpClientImpl {
462459 Err ( acp:: Error :: internal_error ( ) )
463460 }
464461 Err ( _) => {
465- error ! ( "ACP fs response channel dropped for agent {}" , self . agent_id) ;
462+ error ! (
463+ "ACP fs response channel dropped for agent {}" ,
464+ self . agent_id
465+ ) ;
466466 Err ( acp:: Error :: internal_error ( ) )
467467 }
468468 }
@@ -515,7 +515,10 @@ impl Client for AcpClientImpl {
515515 Err ( acp:: Error :: internal_error ( ) )
516516 }
517517 Err ( _) => {
518- error ! ( "ACP fs response channel dropped for agent {}" , self . agent_id) ;
518+ error ! (
519+ "ACP fs response channel dropped for agent {}" ,
520+ self . agent_id
521+ ) ;
519522 Err ( acp:: Error :: internal_error ( ) )
520523 }
521524 }
@@ -782,12 +785,13 @@ impl AcpClientImpl {
782785 if let Some ( raw_input) = tool_call. raw_input . as_ref ( ) {
783786 if let Some ( cmd) = raw_input. get ( "cmd" ) . and_then ( |value| value. as_str ( ) ) {
784787 tool_command = Some ( cmd. to_string ( ) ) ;
785- } else if let Some ( command) = raw_input. get ( "command" ) . and_then ( |value| value. as_str ( ) ) {
788+ } else if let Some ( command) = raw_input. get ( "command" ) . and_then ( |value| value. as_str ( ) )
789+ {
786790 tool_command = Some ( command. to_string ( ) ) ;
787791 }
788792 }
789793
790- // Extract locations from tool call (use relative path if possible)
794+ // Keep ACP locations absolute to match the protocol and avoid path identity mismatches.
791795 let locations = if tool_call. locations . is_empty ( ) {
792796 None
793797 } else {
@@ -796,9 +800,7 @@ impl AcpClientImpl {
796800 . locations
797801 . iter ( )
798802 . map ( |loc| AcpLocation {
799- path : relative_to_current_dir ( & loc. path )
800- . map ( |p| p. to_string_lossy ( ) . to_string ( ) )
801- . unwrap_or_else ( || loc. path . to_string_lossy ( ) . to_string ( ) ) ,
803+ path : loc. path . to_string_lossy ( ) . to_string ( ) ,
802804 line : loc. line ,
803805 } )
804806 . collect ( ) ,
@@ -1148,7 +1150,12 @@ pub struct AcpAgent {
11481150}
11491151
11501152impl AcpAgent {
1151- pub fn new ( agent_id : String , agent_name : String , permission_mode : Arc < AtomicU8 > , fs_sender : mpsc:: Sender < AcpFsCommand > ) -> Self {
1153+ pub fn new (
1154+ agent_id : String ,
1155+ agent_name : String ,
1156+ permission_mode : Arc < AtomicU8 > ,
1157+ fs_sender : mpsc:: Sender < AcpFsCommand > ,
1158+ ) -> Self {
11521159 // Initialize history manager with current working directory and agent ID
11531160 let project_root = std:: env:: current_dir ( ) . unwrap_or_else ( |_| PathBuf :: from ( "." ) ) ;
11541161 let mut history_manager = AcpHistoryManager :: new ( & project_root, & agent_id) ;
@@ -1343,18 +1350,18 @@ impl AcpAgent {
13431350 Self :: spawn_stderr_reader ( stderr, message_sender. clone ( ) , history_for_stderr) ;
13441351
13451352 // Initialize connection and create session
1346- let bootstrap =
1347- match Self :: initialize_connection ( & conn , & agent_id , resume_session_id ) . await {
1348- Ok ( bootstrap) => {
1349- let _ = session_tx. send ( bootstrap. session_id . clone ( ) ) . await ;
1350- ready. store ( true , Ordering :: SeqCst ) ;
1351- Some ( bootstrap)
1352- }
1353- Err ( e) => {
1354- error ! ( "Failed to initialize ACP agent {}: {}" , agent_id, e) ;
1355- None
1356- }
1357- } ;
1353+ let bootstrap = match Self :: initialize_connection ( & conn , & agent_id , resume_session_id ) . await
1354+ {
1355+ Ok ( bootstrap) => {
1356+ let _ = session_tx. send ( bootstrap. session_id . clone ( ) ) . await ;
1357+ ready. store ( true , Ordering :: SeqCst ) ;
1358+ Some ( bootstrap)
1359+ }
1360+ Err ( e) => {
1361+ error ! ( "Failed to initialize ACP agent {}: {}" , agent_id, e) ;
1362+ None
1363+ }
1364+ } ;
13581365
13591366 // Handle prompts in a loop
13601367 if let Some ( bootstrap) = bootstrap {
@@ -1463,7 +1470,10 @@ impl AcpAgent {
14631470 let cwd = std:: env:: current_dir ( ) . unwrap_or_else ( |_| std:: path:: PathBuf :: from ( "." ) ) ;
14641471 let bootstrap = Self :: create_or_resume_session ( conn, resume_session_id, cwd) . await ?;
14651472
1466- info ! ( "Session ready for agent {}: {}" , agent_id, bootstrap. session_id) ;
1473+ info ! (
1474+ "Session ready for agent {}: {}" ,
1475+ agent_id, bootstrap. session_id
1476+ ) ;
14671477 Ok ( bootstrap)
14681478 }
14691479
@@ -1481,9 +1491,7 @@ impl AcpAgent {
14811491 } => {
14821492 error ! (
14831493 "Failed to restore ACP session {}. load_session error: {}. resume_session error: {}. Falling back to creating a new session." ,
1484- resume_session_id,
1485- load_err,
1486- resume_err
1494+ resume_session_id, load_err, resume_err
14871495 ) ;
14881496 }
14891497 }
@@ -1671,7 +1679,9 @@ impl AcpAgent {
16711679
16721680 Ok ( SessionConfigSelectors {
16731681 model_selector : Self :: parse_model_selector ( Some ( response. config_options . as_slice ( ) ) ) ,
1674- reasoning_selector : Self :: parse_reasoning_selector ( Some ( response. config_options . as_slice ( ) ) ) ,
1682+ reasoning_selector : Self :: parse_reasoning_selector ( Some (
1683+ response. config_options . as_slice ( ) ,
1684+ ) ) ,
16751685 } )
16761686 }
16771687
@@ -2053,10 +2063,7 @@ impl AcpAgent {
20532063 Ok ( ( ) )
20542064 }
20552065
2056- pub async fn set_session_config_option (
2057- & self ,
2058- option : AcpSelectOption ,
2059- ) -> Result < ( ) > {
2066+ pub async fn set_session_config_option ( & self , option : AcpSelectOption ) -> Result < ( ) > {
20602067 let config_tx = self
20612068 . config_sender
20622069 . as_ref ( )
0 commit comments