Merge pull request #1785 from KrishavRajSingh/main

remove fallback info
This commit is contained in:
Krishav 2025-10-08 00:54:28 +05:30 committed by GitHub
commit ae04dddf65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 2 deletions

View File

@ -8,6 +8,7 @@ throughout the agent execution pipeline using LiteLLM's standardized exceptions.
from typing import Dict, Any, Optional, Union from typing import Dict, Any, Optional, Union
from dataclasses import dataclass from dataclasses import dataclass
from core.utils.logger import logger from core.utils.logger import logger
import re
# Import LiteLLM exceptions as documented at https://docs.litellm.ai/docs/exception_mapping # Import LiteLLM exceptions as documented at https://docs.litellm.ai/docs/exception_mapping
try: try:
@ -175,9 +176,15 @@ class ErrorProcessor:
@staticmethod @staticmethod
def safe_error_to_string(error: Exception) -> str: 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: 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: except Exception:
try: try:
# Handle case where error.args[0] might be a list or other non-string type # Handle case where error.args[0] might be a list or other non-string type