nailedit confidence - no need to waste tokens on another assistant when it's a no brainer fix for Claude

This commit is contained in:
Fahad
2025-06-19 13:52:37 +04:00
parent 4394ca1061
commit 91acc0bd26

View File

@@ -50,7 +50,14 @@ DEBUG_INVESTIGATION_FIELD_DESCRIPTIONS = {
"hypothesis": ( "hypothesis": (
"Formulate your current best guess about the underlying cause. This is a working theory and may evolve based on further evidence." "Formulate your current best guess about the underlying cause. This is a working theory and may evolve based on further evidence."
), ),
"confidence": "How confident you are in the current hypothesis: 'low', 'medium', or 'high'.", "confidence": (
"How confident you are in the current hypothesis: "
"'low' (initial theory), 'medium' (good evidence), 'high' (strong to very strong evidence), "
"'nailedit' (ONLY use for final step and ONLY when you have found the EXACT root cause with 100% certainty AND "
"identified a simple, minimal fix that requires no expert consultation. Use this ONLY "
"for obvious bugs and logic errors that you ABSOLUTELY are certain about and have no doubts because you have"
"successfully mapped out the code flow and the root cause behind the issue."
),
"backtrack_from_step": "If a previous step needs revision, specify the step number to backtrack from.", "backtrack_from_step": "If a previous step needs revision, specify the step number to backtrack from.",
"continuation_id": "Continuation token used for linking multi-step investigations and continuing conversations after discovery.", "continuation_id": "Continuation token used for linking multi-step investigations and continuing conversations after discovery.",
"images": ( "images": (
@@ -197,7 +204,7 @@ class DebugIssueTool(BaseTool):
}, },
"confidence": { "confidence": {
"type": "string", "type": "string",
"enum": ["low", "medium", "high"], "enum": ["low", "medium", "high", "nailedit"],
"description": DEBUG_INVESTIGATION_FIELD_DESCRIPTIONS["confidence"], "description": DEBUG_INVESTIGATION_FIELD_DESCRIPTIONS["confidence"],
}, },
"backtrack_from_step": { "backtrack_from_step": {
@@ -344,43 +351,72 @@ class DebugIssueTool(BaseTool):
if continuation_id: if continuation_id:
response_data["continuation_id"] = continuation_id response_data["continuation_id"] = continuation_id
# If investigation is complete, call the AI model for expert analysis # If investigation is complete, decide whether to call expert analysis or proceed with minimal fix
if not request.next_step_required: if not request.next_step_required:
response_data["status"] = "calling_expert_analysis"
response_data["investigation_complete"] = True response_data["investigation_complete"] = True
# Prepare consolidated investigation summary # Check if Claude has absolute certainty and can proceed with minimal fix
investigation_summary = self._prepare_investigation_summary() if request.confidence == "nailedit":
# Trust Claude's judgment completely - if it says nailedit, skip expert analysis
response_data["status"] = "nailedit_confidence_proceed_with_fix"
# Call the AI model with full context investigation_summary = self._prepare_investigation_summary()
expert_analysis = await self._call_expert_analysis( response_data["complete_investigation"] = {
initial_issue=getattr(self, "initial_issue", request.step), "initial_issue": getattr(self, "initial_issue", request.step),
investigation_summary=investigation_summary, "steps_taken": len(self.investigation_history),
relevant_files=list(self.consolidated_findings["relevant_files"]), "files_examined": list(self.consolidated_findings["files_checked"]),
relevant_methods=list(self.consolidated_findings["relevant_methods"]), "relevant_files": list(self.consolidated_findings["relevant_files"]),
final_hypothesis=request.hypothesis, "relevant_methods": list(self.consolidated_findings["relevant_methods"]),
error_context=self._extract_error_context(), "investigation_summary": investigation_summary,
images=list(set(self.consolidated_findings["images"])), # Unique images "final_hypothesis": request.hypothesis,
model_info=arguments.get("_model_context"), # Use pre-resolved model context from server.py "confidence_level": "nailedit",
arguments=arguments, # Pass arguments for model resolution }
request=request, # Pass request for model resolution response_data["next_steps"] = (
) "Investigation complete with NAILED-IT confidence. You have identified the exact "
"root cause and a minimal fix. Proceed directly with implementing the simple fix "
"without requiring expert consultation. Focus on the precise, minimal change needed."
)
response_data["skip_expert_analysis"] = True
response_data["expert_analysis"] = {
"status": "skipped_due_to_nailedit_confidence",
"reason": "Claude identified exact root cause with minimal fix requirement",
}
else:
# Standard expert analysis for high/medium/low confidence
response_data["status"] = "calling_expert_analysis"
# Combine investigation and expert analysis # Prepare consolidated investigation summary
response_data["expert_analysis"] = expert_analysis investigation_summary = self._prepare_investigation_summary()
response_data["complete_investigation"] = {
"initial_issue": getattr(self, "initial_issue", request.step), # Call the AI model with full context
"steps_taken": len(self.investigation_history), expert_analysis = await self._call_expert_analysis(
"files_examined": list(self.consolidated_findings["files_checked"]), initial_issue=getattr(self, "initial_issue", request.step),
"relevant_files": list(self.consolidated_findings["relevant_files"]), investigation_summary=investigation_summary,
"relevant_methods": list(self.consolidated_findings["relevant_methods"]), relevant_files=list(self.consolidated_findings["relevant_files"]),
"investigation_summary": investigation_summary, relevant_methods=list(self.consolidated_findings["relevant_methods"]),
} final_hypothesis=request.hypothesis,
response_data["next_steps"] = ( error_context=self._extract_error_context(),
"Investigation complete with expert analysis. Present the findings, hypotheses, " images=list(set(self.consolidated_findings["images"])), # Unique images
"and recommended fixes to the user. Focus on the most likely root cause and " model_info=arguments.get("_model_context"), # Use pre-resolved model context from server.py
"provide actionable implementation guidance." arguments=arguments, # Pass arguments for model resolution
) request=request, # Pass request for model resolution
)
# Combine investigation and expert analysis
response_data["expert_analysis"] = expert_analysis
response_data["complete_investigation"] = {
"initial_issue": getattr(self, "initial_issue", request.step),
"steps_taken": len(self.investigation_history),
"files_examined": list(self.consolidated_findings["files_checked"]),
"relevant_files": list(self.consolidated_findings["relevant_files"]),
"relevant_methods": list(self.consolidated_findings["relevant_methods"]),
"investigation_summary": investigation_summary,
}
response_data["next_steps"] = (
"Investigation complete with expert analysis. Present the findings, hypotheses, "
"and recommended fixes to the user. Focus on the most likely root cause and "
"provide actionable implementation guidance."
)
else: else:
response_data["next_steps"] = ( response_data["next_steps"] = (
f"Continue investigation with step {request.step_number + 1}. " f"Continue investigation with step {request.step_number + 1}. "