mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-26 06:03:19 +00:00
A chat-completions call on a responses-mode deployment wraps the BaseResponsesAPIStreamingIterator in a CustomStreamWrapper and both layers share one Logging object, so a mid-stream failure has two dispatch sites: the inner iterator fires the failure handlers before re-raising and the outer wrapper fires them again for the same exception. The dedup that stops the second dispatch is has_logged_async_failure, which mark_logging_complete must keep setting for failure events on streams: the stream=True carve-out applies to success events only, because a stream is one request whose failure must be logged once, while success markers are per-chunk and cannot be one-shot. Before the logging split this marker was skipped for every event type on a stream, so CustomLogger.async_log_failure_event fired twice for the same exception object with identical start_time/end_time, and the fire-and-forget outer task often ran after the router had started a fallback hop, so the duplicate got attributed to whatever deployment the logging object described at that moment (reported in #46557 as a fallback deployment showing a ~50% phantom error rate). Pin both failure shapes with a regression test that rebuilds the exact bridge stack (SSE responses iterator, responses-to-chat translation iterator, CustomStreamWrapper, one Logging object) and asserts exactly one async failure event per failed stream, both after streamed output and before the first chunk. Verified both directions: on current main exactly one event is dispatched; reverting mark_logging_complete to the pre-split behavior (skip the marker for all event types on streams) makes both tests fail with two events carrying identical exception objects and identical timestamps, matching the issue report. Refs #46557 Signed-off-by: choksi2212 <choksi2212@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| _support | ||
| base_sdk_tests | ||
| benchmarks | ||
| code_coverage_tests | ||
| documentation_tests | ||
| e2e | ||
| e2e_harness | ||
| fixtures | ||
| harness_e2e | ||
| integration | ||
| rust-python-harness | ||
| test_litellm_rust | ||
| typing | ||
| unit | ||
| windows_tests | ||
| __init__.py | ||
| _fake_openai_endpoint_server.py | ||
| _flush_vcr_cache.py | ||
| _live_test_helpers.py | ||
| _master_key.py | ||
| _openai_record_replay_proxy.py | ||
| _process_helpers.py | ||
| _vcr_conftest_common.py | ||
| _vcr_redis_persister.py | ||
| _wait_helpers.py | ||
| _ws_vcr.py | ||
| AGENTS.md | ||
| capturing_transport.py | ||
| eval_swe_bench.py | ||
| fake_openai_endpoint.py | ||
| gettysburg.wav | ||
| large_text.py | ||
| openai_batch_completions.jsonl | ||
| pyrightconfig.json | ||
| README.MD | ||
| test_logging.conf | ||
| test_rust_python_harness.py | ||
| VCR_TESTING.md | ||
| white_100x100.png | ||
In total litellm runs 1000+ tests
[02/20/2025] Update:
To make it easier to contribute and map what behavior is tested,
we've started mapping the litellm directory in tests/unit
This folder can only run mock tests.