@@ -640,47 +640,43 @@ impl ApiClient {
640640 self . set_mock_llm ( move |mut ctx| {
641641 let response_groups = response_groups. clone ( ) ;
642642 async move {
643- // Determine which response group to use based on user message count
644- // Each user message gets the next response group in sequence
645- let response_index = ctx. count_user_messages ( ) . saturating_sub ( 1 ) ; // 0-indexed
646-
647- // Send the corresponding response group
648- if response_index < response_groups. len ( ) {
649- for event in & response_groups[ response_index] {
650- match event {
651- ChatResponseStream :: AssistantResponseEvent { content } => {
652- ctx. respond ( content) . await ?;
653- } ,
654- ChatResponseStream :: ToolUseEvent { tool_use_id, name, input, stop } => {
655- // For tool events, we need to create proper tool use structure
656- if stop. unwrap_or ( false ) {
657- // This is a complete tool use - parse the arguments
658- let args = input. as_ref ( ) . map ( |s| {
659- serde_json:: from_str ( s) . unwrap_or ( serde_json:: Value :: String ( s. clone ( ) ) )
660- } ) . unwrap_or ( serde_json:: Value :: Null ) ;
661-
662- let _tool_use = crate :: cli:: chat:: AssistantToolUse {
663- id : tool_use_id. clone ( ) ,
664- name : name. clone ( ) ,
665- orig_name : name. clone ( ) ,
666- args : args. clone ( ) ,
667- orig_args : args,
668- } ;
669-
670- // For now, just send text response about tool use since we don't have direct tool event API
671- // TODO: Implement proper tool event support in MockLLMContext if needed
672- ctx. respond ( format ! ( "[Tool: {} with args: {}]" , name, tool_use_id) ) . await ?;
673- }
674- } ,
675- _ => { } , // Ignore other event types
643+ // Determine which response group to use based on user message count
644+ // Each user message gets the next response group in sequence
645+ let response_index = ctx. count_user_messages ( ) . saturating_sub ( 1 ) ; // 0-indexed
646+
647+ tracing:: debug!(
648+ actor="MockLLM" ,
649+ user_message=ctx. current_user_message( ) ,
650+ count=ctx. count_user_messages( ) ,
651+ response_index,
652+ response_groups=?response_groups,
653+ ) ;
654+
655+ // Send the corresponding response group
656+ if response_index < response_groups. len ( ) {
657+ for event in & response_groups[ response_index] {
658+ match event {
659+ ChatResponseStream :: AssistantResponseEvent { content } => {
660+ ctx. respond ( content) . await ?;
661+ } ,
662+ ChatResponseStream :: ToolUseEvent {
663+ tool_use_id,
664+ name,
665+ input,
666+ stop,
667+ } => {
668+ ctx. respond_tool_use ( tool_use_id. clone ( ) , name. clone ( ) , input. clone ( ) , stop. clone ( ) )
669+ . await ?;
670+ } ,
671+ _ => { } , // Ignore other event types
672+ }
676673 }
674+ } else {
675+ // No more predefined responses, send a fallback
676+ ctx. respond ( "I don't have a response configured for this message." ) . await ?;
677677 }
678- } else {
679- // No more predefined responses, send a fallback
680- ctx. respond ( "I don't have a response configured for this message." ) . await ?;
681- }
682-
683- Ok ( ( ) )
678+
679+ Ok ( ( ) )
684680 }
685681 } ) ;
686682 }
0 commit comments