-
Notifications
You must be signed in to change notification settings - Fork 125
Open
Description
Bug: AttributeError - 'Exception' object has no attribute 'request'
Error
'Exception' object has no attribute 'request'
Environment
- LiteLLM + CrewAI + OpenRouter API
- Python 3.12
- Model: qwen/qwen3-8b
Problem
When OpenRouter API returns an error, LiteLLM's exception mapper tries to access exception.request attribute, but not all exception types have this attribute.
Root Cause
File: litellm/litellm_core_utils/exception_mapping_utils.py (lines 1444, 1519, 1578, etc.)
raise BadRequestError(
...
request=original_exception.request, # ❌ Assumes .request exists
)Impact
- Tool calls fail repeatedly
- Agent gets stuck in infinite loop
- Tasks never complete
- No retry mechanism triggered
Suggested Fix
Use safe attribute access:
request=getattr(original_exception, 'request', None), # ✅ SafeReproduce
- Run agent with OpenRouter API
- Wait for intermittent API error
- Observe AttributeError in logs
Logs
2025-10-17 08:10:28 - stratus.tools.kubectl.nl2kubectl - ERROR - NL2Kubectl Tool failed with: 'Exception' object has no attribute 'request'
Error repeats every 2-5 minutes, agent never exits.
gagansoCopilot
Metadata
Metadata
Assignees
Labels
No labels