diff --git a/backend/core/agentpress/error_processor.py b/backend/core/agentpress/error_processor.py index c6b415e0..6680d12f 100644 --- a/backend/core/agentpress/error_processor.py +++ b/backend/core/agentpress/error_processor.py @@ -8,6 +8,7 @@ throughout the agent execution pipeline using LiteLLM's standardized exceptions. from typing import Dict, Any, Optional, Union from dataclasses import dataclass from core.utils.logger import logger +import re # Import LiteLLM exceptions as documented at https://docs.litellm.ai/docs/exception_mapping try: @@ -175,9 +176,15 @@ class ErrorProcessor: @staticmethod def safe_error_to_string(error: Exception) -> str: - """Safely convert an exception to a string with fallbacks.""" + """Safely convert an exception to a string, cleaning up verbose LiteLLM error messages.""" try: - return str(error) + error_str = str(error) + # remove fallback information + if "Fallbacks=[" in error_str: + error_str = re.sub(r'Fallbacks=\[(?:[^\[\]]+|\[(?:[^\[\]]+|\[[^\[\]]*\])*\])*\]', '', error_str) + + return error_str + except Exception: try: # Handle case where error.args[0] might be a list or other non-string type