@@ -2,15 +2,15 @@ use std::collections::HashMap;
22use std:: sync:: Arc ;
33use std:: time:: Duration ;
44
5- use async_trait:: async_trait;
6- use codex_protocol:: models:: ResponseInputItem ;
7- use tracing:: warn;
8-
95use crate :: client_common:: tools:: ToolSpec ;
106use crate :: function_tool:: FunctionCallError ;
117use crate :: tools:: context:: ToolInvocation ;
128use crate :: tools:: context:: ToolOutput ;
139use crate :: tools:: context:: ToolPayload ;
10+ use async_trait:: async_trait;
11+ use codex_protocol:: models:: ResponseInputItem ;
12+ use codex_utils_readiness:: Readiness ;
13+ use tracing:: warn;
1414
1515#[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
1616pub enum ToolKind {
@@ -30,6 +30,10 @@ pub trait ToolHandler: Send + Sync {
3030 )
3131 }
3232
33+ fn is_mutating ( & self , _invocation : & ToolInvocation ) -> bool {
34+ false
35+ }
36+
3337 async fn handle ( & self , invocation : ToolInvocation ) -> Result < ToolOutput , FunctionCallError > ;
3438}
3539
@@ -106,6 +110,11 @@ impl ToolRegistry {
106110 let output_cell = & output_cell;
107111 let invocation = invocation;
108112 async move {
113+ if handler. is_mutating ( & invocation) {
114+ tracing:: trace!( "waiting for tool gate" ) ;
115+ invocation. turn . tool_call_gate . wait_ready ( ) . await ;
116+ tracing:: trace!( "tool gate released" ) ;
117+ }
109118 match handler. handle ( invocation) . await {
110119 Ok ( output) => {
111120 let preview = output. log_preview ( ) ;
0 commit comments