SergeyO7 commited on
Commit
037d0e9
·
verified ·
1 Parent(s): 10363bd

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +17 -1
agent.py CHANGED
@@ -388,4 +388,20 @@ class MagAgent:
388
  )
389
 
390
  def _validate_and_format(self, result: str, context: dict) -> str:
391
- validation = ValidationPipeline().validate
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  )
389
 
390
  def _validate_and_format(self, result: str, context: dict) -> str:
391
+ validation = ValidationPipeline().validate
392
+
393
+ def _handle_error(self, error: Exception, context: dict) -> str:
394
+ """Central error handling with context-aware formatting"""
395
+ error_type = error.__class__.__name__
396
+ error_msg = str(error)
397
+
398
+ # Store error in validation context
399
+ context["validation_checks"].append({
400
+ "type": "error",
401
+ "error_type": error_type,
402
+ "message": error_msg,
403
+ "timestamp": datetime.now().isoformat()
404
+ })
405
+
406
+ # Format user-facing message
407
+ return f"AGENT ERROR: {error_type} - {error_msg}"