@@ -505,8 +505,6 @@ pub struct ChatContext {
505505 tool_use_telemetry_events : HashMap < String , ToolUseEventBuilder > ,
506506 /// State used to keep track of tool use relation
507507 tool_use_status : ToolUseStatus ,
508- /// Abstraction that consolidates custom tools with native ones
509- tool_manager : ToolManager ,
510508 /// Any failed requests that could be useful for error report/debugging
511509 failed_request_ids : Vec < String > ,
512510 /// Pending prompts to be sent
@@ -533,8 +531,15 @@ impl ChatContext {
533531 ) -> Result < Self > {
534532 let ctx_clone = Arc :: clone ( & ctx) ;
535533 let output_clone = output. clone ( ) ;
536- let conversation_state =
537- ConversationState :: new ( ctx_clone, conversation_id, tool_config, profile, Some ( output_clone) ) . await ;
534+ let conversation_state = ConversationState :: new (
535+ ctx_clone,
536+ conversation_id,
537+ tool_config,
538+ profile,
539+ Some ( output_clone) ,
540+ tool_manager,
541+ )
542+ . await ;
538543 Ok ( Self {
539544 ctx,
540545 settings,
@@ -550,7 +555,6 @@ impl ChatContext {
550555 conversation_state,
551556 tool_use_telemetry_events : HashMap :: new ( ) ,
552557 tool_use_status : ToolUseStatus :: Idle ,
553- tool_manager,
554558 failed_request_ids : Vec :: new ( ) ,
555559 pending_prompts : VecDeque :: new ( ) ,
556560 } )
@@ -1217,6 +1221,7 @@ impl ChatContext {
12171221 #[ cfg( unix) ]
12181222 if let Some ( ref context_manager) = self . conversation_state . context_manager {
12191223 let tool_names = self
1224+ . conversation_state
12201225 . tool_manager
12211226 . tn_map
12221227 . keys ( )
@@ -2152,9 +2157,10 @@ impl ChatContext {
21522157
21532158 match subcommand {
21542159 Some ( ToolsSubcommand :: Schema ) => {
2155- let schema_json = serde_json:: to_string_pretty ( & self . tool_manager . schema ) . map_err ( |e| {
2156- ChatError :: Custom ( format ! ( "Error converting tool schema to string: {e}" ) . into ( ) )
2157- } ) ?;
2160+ let schema_json = serde_json:: to_string_pretty ( & self . conversation_state . tool_manager . schema )
2161+ . map_err ( |e| {
2162+ ChatError :: Custom ( format ! ( "Error converting tool schema to string: {e}" ) . into ( ) )
2163+ } ) ?;
21582164 queue ! ( self . output, style:: Print ( schema_json) , style:: Print ( "\n " ) ) ?;
21592165 } ,
21602166 Some ( ToolsSubcommand :: Trust { tool_names } ) => {
@@ -2368,7 +2374,7 @@ impl ChatContext {
23682374 } ,
23692375 Some ( PromptsSubcommand :: Get { mut get_command } ) => {
23702376 let orig_input = get_command. orig_input . take ( ) ;
2371- let prompts = match self . tool_manager . get_prompt ( get_command) . await {
2377+ let prompts = match self . conversation_state . tool_manager . get_prompt ( get_command) . await {
23722378 Ok ( resp) => resp,
23732379 Err ( e) => {
23742380 match e {
@@ -2455,12 +2461,12 @@ impl ChatContext {
24552461 _ => None ,
24562462 } ;
24572463 let terminal_width = self . terminal_width ( ) ;
2458- let mut prompts_wl = self . tool_manager . prompts . write ( ) . map_err ( |e| {
2464+ let mut prompts_wl = self . conversation_state . tool_manager . prompts . write ( ) . map_err ( |e| {
24592465 ChatError :: Custom (
24602466 format ! ( "Poison error encountered while retrieving prompts: {}" , e) . into ( ) ,
24612467 )
24622468 } ) ?;
2463- self . tool_manager . refresh_prompts ( & mut prompts_wl) ?;
2469+ self . conversation_state . tool_manager . refresh_prompts ( & mut prompts_wl) ?;
24642470 let mut longest_name = "" ;
24652471 let arg_pos = {
24662472 let optimal_case = UnicodeWidthStr :: width ( longest_name) + terminal_width / 4 ;
@@ -3126,7 +3132,7 @@ impl ChatContext {
31263132 . set_tool_use_id ( tool_use_id. clone ( ) )
31273133 . set_tool_name ( tool_use. name . clone ( ) )
31283134 . utterance_id ( self . conversation_state . message_id ( ) . map ( |s| s. to_string ( ) ) ) ;
3129- match self . tool_manager . get_tool_from_tool_use ( tool_use) {
3135+ match self . conversation_state . tool_manager . get_tool_from_tool_use ( tool_use) {
31303136 Ok ( mut tool) => {
31313137 // Apply non-Q-generated context to tools
31323138 self . contextualize_tool ( & mut tool) ;
0 commit comments