From b369a1f5c39c702590b7d48ba3bc05a6f77bd84f Mon Sep 17 00:00:00 2001 From: Dhanji Prasanna Date: Wed, 8 Oct 2025 11:12:11 +1100 Subject: [PATCH] fixes for coach mode --- crates/g3-cli/src/lib.rs | 36 +++++++++++++++++++++++++++++------- crates/g3-core/src/lib.rs | 8 +++++++- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/crates/g3-cli/src/lib.rs b/crates/g3-cli/src/lib.rs index fa8cce3..333ae73 100644 --- a/crates/g3-cli/src/lib.rs +++ b/crates/g3-cli/src/lib.rs @@ -743,11 +743,12 @@ Review the current state of the project and provide a concise critique focusing 3. What requirements are missing or incorrect 4. Specific improvements needed to satisfy requirements -If the implementation correctly meets all requirements, respond with: 'IMPLEMENTATION_APPROVED' -If improvements are needed, provide specific actionable feedback. Be thorough but don't be overly critical. APPROVE the -implementation if it doesn't have compile errors, glaring omissions and generally fits the bill. +IMPORTANT: You MUST use the final_output tool to provide your feedback. -Keep your response concise and focused on actionable items.", +If the implementation correctly meets all requirements, call final_output with summary: 'IMPLEMENTATION_APPROVED' +If improvements are needed, call final_output with specific actionable feedback as the summary. + +Be thorough but don't be overly critical. APPROVE the implementation if it doesn't have compile errors, glaring omissions and generally fits the bill.", requirements ); @@ -757,10 +758,31 @@ Keep your response concise and focused on actionable items.", .await?; output.print("šŸŽ“ Coach review completed"); - output.print(&format!("Coach feedback: {}", coach_result)); + + // Extract the actual feedback text from the coach result + // The coach_result might contain timing information at the end (ā±ļø ... | šŸ’­ ...) + // We need to extract just the feedback content + let coach_feedback_text = if let Some(timing_pos) = coach_result.rfind("\nā±ļø") { + coach_result[..timing_pos].trim().to_string() + } else { + coach_result.trim().to_string() + }; + + // Check if we got empty feedback (this can happen if the coach doesn't call final_output) + if coach_feedback_text.is_empty() { + output.print("āš ļø Coach did not provide feedback. This may be a model issue."); + output.print(" Retrying with a more explicit prompt..."); + + // For now, we'll treat empty feedback as needing improvements + coach_feedback = "The implementation needs review. Please ensure all requirements are met and the code compiles without errors.".to_string(); + turn += 1; + continue; + } + + output.print(&format!("Coach feedback:\n{}", coach_feedback_text)); // Check if coach approved the implementation - if coach_result.contains("IMPLEMENTATION_APPROVED") { + if coach_feedback_text.contains("IMPLEMENTATION_APPROVED") { output.print("\n=== SESSION COMPLETED - IMPLEMENTATION APPROVED ==="); output.print("āœ… Coach approved the implementation!"); implementation_approved = true; @@ -775,7 +797,7 @@ Keep your response concise and focused on actionable items.", } // Store coach feedback for next iteration - coach_feedback = coach_result; + coach_feedback = coach_feedback_text; turn += 1; output.print("šŸ”„ Coach provided feedback for next iteration"); diff --git a/crates/g3-core/src/lib.rs b/crates/g3-core/src/lib.rs index 1d538ee..e3c97b8 100644 --- a/crates/g3-core/src/lib.rs +++ b/crates/g3-core/src/lib.rs @@ -1385,7 +1385,13 @@ The tool will execute immediately and you'll receive the result (success or erro full_response.push_str(final_display_content); if let Some(summary) = tool_call.args.get("summary") { if let Some(summary_str) = summary.as_str() { - full_response.push_str(&format!("\n\n=> {}", summary_str)); + // Don't add the "=> " prefix in autonomous mode + // as it interferes with coach feedback parsing + if !self.is_autonomous { + full_response.push_str(&format!("\n\n=> {}", summary_str)); + } else { + full_response.push_str(&format!("\n\n{}", summary_str)); + } } } self.ui_writer.println("");