File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3831,6 +3831,11 @@ pub(crate) async fn run_unified_loop_impl(
38313831 compression_retry_floor. is_some_and ( |floor| estimated_tokens <= floor) ;
38323832 let mut compressible_sufficient = true ;
38333833 if compression_cfg. enabled && payload > soft && !retry_blocked {
3834+ let leading_system_tokens: usize = history
3835+ . iter ( )
3836+ . take_while ( |m| m. role == "system" )
3837+ . map ( crate :: providers:: traits:: estimate_message_tokens)
3838+ . sum ( ) ;
38343839 let preserved_now = current_turn_preserved_indices ( history) ;
38353840 let compressible =
38363841 crate :: agent:: context:: compressor:: estimate_compressible_tokens (
@@ -3842,6 +3847,19 @@ pub(crate) async fn run_unified_loop_impl(
38423847 let needed = payload. saturating_sub ( soft) ;
38433848 compressible_sufficient =
38443849 compressible. saturating_mul ( 4 ) >= needed. saturating_mul ( 5 ) ;
3850+ tracing:: debug!(
3851+ target: "agent.context.compress" ,
3852+ payload,
3853+ soft,
3854+ hard,
3855+ leading_system_tokens,
3856+ tools_overhead = tools_overhead_tokens,
3857+ history_tokens = estimated_tokens,
3858+ compressible,
3859+ needed,
3860+ sufficient = compressible_sufficient,
3861+ "compaction gate evaluated: payload composition and compressible headroom"
3862+ ) ;
38453863 if !compressible_sufficient {
38463864 tracing:: debug!(
38473865 target: "agent.context.compress" ,
Original file line number Diff line number Diff line change @@ -2468,7 +2468,10 @@ pub async fn handle_api_session_delete(
24682468 . unwrap_or_else ( |e| Err ( std:: io:: Error :: other ( e. to_string ( ) ) ) )
24692469 } ;
24702470 match result {
2471- Ok ( true ) => Json ( serde_json:: json!( { "ok" : true } ) ) . into_response ( ) ,
2471+ Ok ( true ) => {
2472+ crate :: agent:: context:: compressor:: set_session_compression_floor ( & id, None ) ;
2473+ Json ( serde_json:: json!( { "ok" : true } ) ) . into_response ( )
2474+ }
24722475 Ok ( false ) => (
24732476 StatusCode :: NOT_FOUND ,
24742477 Json ( serde_json:: json!( { "error" : "Session not found" } ) ) ,
@@ -2527,7 +2530,17 @@ pub async fn handle_api_sessions_delete_batch(
25272530 } ;
25282531
25292532 match result {
2530- Ok ( deleted) => Json ( serde_json:: json!( { "ok" : true , "deleted" : deleted } ) ) . into_response ( ) ,
2533+ Ok ( deleted) => {
2534+ for id in & body. ids {
2535+ let trimmed = id. trim ( ) ;
2536+ if !trimmed. is_empty ( ) {
2537+ crate :: agent:: context:: compressor:: set_session_compression_floor (
2538+ trimmed, None ,
2539+ ) ;
2540+ }
2541+ }
2542+ Json ( serde_json:: json!( { "ok" : true , "deleted" : deleted } ) ) . into_response ( )
2543+ }
25312544 Err ( e) => {
25322545 tracing:: error!( "Failed to batch-delete sessions: {e}" ) ;
25332546 (
@@ -3186,6 +3199,8 @@ pub async fn handle_api_session_rewind(
31863199 . into_response ( ) ;
31873200 }
31883201
3202+ crate :: agent:: context:: compressor:: set_session_compression_floor ( & id, None ) ;
3203+
31893204 crate :: gateway:: ws:: desktop:: broadcast_session_event (
31903205 & id,
31913206 & serde_json:: json!( {
Original file line number Diff line number Diff line change @@ -97,6 +97,17 @@ impl Tool for PowerShellTool {
9797 . and_then ( |v| v. as_str ( ) )
9898 . ok_or_else ( || anyhow:: anyhow!( "Missing 'command' parameter" ) ) ?;
9999
100+ if command. trim ( ) . is_empty ( ) {
101+ return Ok ( ToolResult {
102+ success : false ,
103+ output : String :: new ( ) ,
104+ error : Some (
105+ "The 'command' parameter is empty. Provide the exact PowerShell command to run."
106+ . to_string ( ) ,
107+ ) ,
108+ } ) ;
109+ }
110+
100111 let working_dir = args. get ( "working_directory" ) . and_then ( |v| v. as_str ( ) ) ;
101112 let timeout = args
102113 . get ( "timeout_secs" )
Original file line number Diff line number Diff line change @@ -699,6 +699,17 @@ impl Tool for ShellTool {
699699 . and_then ( |v| v. as_str ( ) )
700700 . ok_or_else ( || anyhow:: anyhow!( "Missing 'command' parameter" ) ) ?;
701701
702+ if command. trim ( ) . is_empty ( ) {
703+ return Ok ( ToolResult {
704+ success : false ,
705+ output : String :: new ( ) ,
706+ error : Some (
707+ "The 'command' parameter is empty. Provide the exact shell command to run."
708+ . to_string ( ) ,
709+ ) ,
710+ } ) ;
711+ }
712+
702713 let preflight = match crate :: tools:: shell:: preflight:: acquire_shell_execution_clearance (
703714 & self . security ,
704715 command,
You can’t perform that action at this time.
0 commit comments