@@ -24,13 +24,15 @@ pub enum ToolCallOutcome {
2424 Unary ( ToolCallResult ) ,
2525}
2626
27- /// Single owner of per-call context (Oracle #4). diagnostics_on_edit has ONE source here.
27+ /// Server-owned settings for a single `tool_call` request.
28+ /// These fields cannot be supplied through the agent's arguments object.
2829#[ derive( Debug , Clone ) ]
2930pub struct ToolCallContext {
3031 pub project_root : PathBuf ,
3132 pub session_id : Option < String > ,
3233 pub request_id : String ,
3334 pub diagnostics_on_edit : bool ,
35+ pub preview : bool ,
3436}
3537
3638pub fn run_tool_call (
@@ -40,17 +42,19 @@ pub fn run_tool_call(
4042 app_ctx : & AppContext ,
4143 dispatch : & DispatchFn < ' _ > ,
4244) -> ToolCallOutcome {
45+ let sanitized_args = strip_agent_preview_arg ( args) ;
4346 let format_context = crate :: subc_format:: FormatContext :: from_tool_call (
4447 bare_name,
45- args ,
48+ & sanitized_args ,
4649 ctx. project_root . as_path ( ) ,
4750 ) ;
4851 let translate_context = crate :: subc_translate:: TranslateContext {
4952 diagnostics_on_edit : ctx. diagnostics_on_edit ,
53+ preview : ctx. preview ,
5054 } ;
5155 let ( command, translated_args) = match crate :: subc_translate:: subc_translate_with_context (
5256 bare_name,
53- args ,
57+ & sanitized_args ,
5458 ctx. project_root . as_path ( ) ,
5559 translate_context,
5660 ) {
@@ -64,7 +68,7 @@ pub fn run_tool_call(
6468 ) ) ;
6569 }
6670 Err ( _) => {
67- let map = args . as_object ( ) . cloned ( ) . unwrap_or_default ( ) ;
71+ let map = sanitized_args . as_object ( ) . cloned ( ) . unwrap_or_default ( ) ;
6872 ( bare_name. to_string ( ) , map)
6973 }
7074 } ;
@@ -98,6 +102,19 @@ pub fn run_tool_call(
98102 ) )
99103}
100104
105+ fn strip_agent_preview_arg ( args : & Value ) -> Value {
106+ let Some ( map) = args. as_object ( ) else {
107+ return args. clone ( ) ;
108+ } ;
109+ if !map. contains_key ( "preview" ) {
110+ return args. clone ( ) ;
111+ }
112+
113+ let mut sanitized = map. clone ( ) ;
114+ sanitized. remove ( "preview" ) ;
115+ Value :: Object ( sanitized)
116+ }
117+
101118fn tool_call_result_from_response (
102119 bare_name : & str ,
103120 format_context : & crate :: subc_format:: FormatContext ,
0 commit comments