Commit Graph

5 Commits

Author SHA1 Message Date
Devin AI
0938968a20 Fix Python 3.11 validation test failures: Remove global logger state and improve error handling
- Remove global _litellm_logger variable that could interfere with exception propagation
- Add proper error handling around logger.setLevel() operations
- Update tests to reflect removal of global caching
- Ensure context manager is fully isolated and doesn't affect validation methods

Co-Authored-By: João <joao@crewai.com>
2025-06-12 00:37:20 +00:00
Devin AI
7e490f73df Fix logger caching test: Reset global state for consistent testing
Co-Authored-By: João <joao@crewai.com>
2025-06-12 00:08:23 +00:00
Devin AI
bab03b2be1 Address review feedback: Add logger caching, improve error handling, expand tests
- Cache litellm logger instance globally for performance optimization
- Implement more specific warning pattern filtering instead of broad matching
- Add robust error handling with graceful degradation in suppression
- Enhance streaming error handling with better logging and continue logic
- Add 3 new comprehensive tests:
  - test_concurrent_llm_calls: Verify thread safety with concurrent LLM calls
  - test_logger_caching_performance: Confirm logger instance caching works
  - test_suppression_error_handling: Test graceful degradation on logger errors
- Fix all lint errors (unused imports) in test file

Co-Authored-By: João <joao@crewai.com>
2025-06-11 23:46:58 +00:00
Devin AI
5fcfba82dc Fix lint errors: Remove unused imports
- Remove unused contextlib, sys, threading, io, TextIO imports from llm.py
- Remove unused importlib import from test_sys_stream_hijacking.py
- Address Ruff lint failures from CI

Co-Authored-By: João <joao@crewai.com>
2025-06-11 23:38:37 +00:00
Devin AI
519af74cf7 Fix issue #3000: Replace global sys.stdout/stderr hijacking with contextual suppression
- Remove FilteredStream class that globally hijacked sys.stdout and sys.stderr
- Replace with logging-based suppression using litellm logger level control
- Add contextual suppression around litellm.completion calls only
- Add comprehensive tests to verify fix and prevent regression
- Ensure streaming responses work correctly without interference
- Maintain litellm output filtering during LLM calls only

Co-Authored-By: João <joao@crewai.com>
2025-06-11 23:34:20 +00:00