kshitijthakkar commited on
Commit
4b91aa4
·
1 Parent(s): cd2758f

fix: Add defensive checks for optional columns in failure analysis

Browse files
Files changed (1) hide show
  1. mcp_tools.py +12 -5
mcp_tools.py CHANGED
@@ -764,12 +764,19 @@ async def analyze_results(
764
  # Analyze failures
765
  failure_analysis = []
766
  if len(failed) > 0:
767
- # Get sample of failures
768
- failure_sample = failed.head(10)[
769
- ['task_id', 'prompt', 'error', 'error_type', 'tool_called', 'expected_tool']
770
- ].to_dict('records')
 
 
 
 
 
 
 
771
 
772
- # Count error types
773
  if 'error_type' in failed.columns:
774
  error_type_counts = failed['error_type'].value_counts().to_dict()
775
  else:
 
764
  # Analyze failures
765
  failure_analysis = []
766
  if len(failed) > 0:
767
+ # Define which columns to include in failure sample
768
+ failure_columns = ['task_id', 'prompt']
769
+
770
+ # Add optional columns if they exist
771
+ optional_columns = ['error', 'error_type', 'tool_called', 'expected_tool']
772
+ for col in optional_columns:
773
+ if col in failed.columns:
774
+ failure_columns.append(col)
775
+
776
+ # Get sample of failures with only existing columns
777
+ failure_sample = failed.head(10)[failure_columns].to_dict('records')
778
 
779
+ # Count error types if column exists
780
  if 'error_type' in failed.columns:
781
  error_type_counts = failed['error_type'].value_counts().to_dict()
782
  else: