mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-24 22:09:56 +00:00
* fix(proxy): settle a Responses WebSocket's key TPM admission reservation when the socket closes A Responses WebSocket reserves key TPM once at admission, but each turn logs under its own call id, so the limiter's success and failure callbacks never find the connection's stash and the reservation stayed counted until the window rolled over. Closing the socket only freed the parallel slot, so a few short sockets could lock a key out of its TPM limit On close the proxy now releases the slot and refunds the whole reservation through the v3 limiter, sharing the settle logic with the post-call failure hook. A lock on the stash makes the refund happen once even when the failure row and the close settle at the same time * test(proxy): a Responses WebSocket close whose refund fails still frees its slot * fix(proxy): drop a Responses WebSocket close refund whose rate-limit window already rolled over * fix(proxy): keep the Responses WebSocket release method name and the failure hook's log line ProxyLogging.arelease_responses_websocket_slot shipped in v1.107.0, so it keeps its name. The failure hook logs its old "Error releasing TPM reservation on post-call failure" line again, and a failure hook whose refund fails still frees its slot without raising * fix(proxy): settle a closed Responses WebSocket's reservations by how it ended A socket closed mid-turn keeps every reservation, since a cut turn charges nothing. A socket whose turns finished refunds its TPM but keeps the team PTU estimate, since turns never charge PTU. A socket a later pre-call hook refused at open frees its slot and every reservation * fix(responses): report a managed socket turn the session limit cancels as unfinished * fix(proxy): settle a closed socket's TPM after its turns log and keep HTTP refunds unguarded A socket whose turns all finished now waits up to 5 s for those turns' logging before it refunds its key, team and user TPM, so the key never counts less than it used. The slot is freed before the wait. HTTP settles go back to main's plain refund, so a failed Redis window check no longer drops an HTTP request's refund. Pass-through routes with no turn classifier leave the reservation to their session row, as on main, and arelease_responses_websocket_slot accepts one argument again. * fix(proxy): close a socket's client before its release waits on turn logging When the upstream or the session limit ends a Responses WebSocket, the client's close now goes out before the release waits for the turns' logging, so the client never waits on logging. A socket closed with a turn still open marks its reservation kept before its first await, so its failure row cannot refund it first * fix(proxy): leave a Responses WebSocket's reservation to its close and send no close frame main never sent The native socket's route no longer closes the client itself when the relay ends, so the client sees what it saw on main, and a finished socket's refund waits for turn logging in the background. A socket's failure row now frees only its slot, and a relay that fails before it returns closes as refused at open, so it refunds everything * fix(proxy): free a legacy limiter's slot when a Responses WebSocket relay fails * test(proxy): wait for a closed socket's refund before opening the next socket * fix(proxy): keep a pass-through socket's reservation when its handler is cancelled mid-turn A cancelled pass-through handler skipped the drain that marks a turn as cut, so its close refunded the reservation of a turn that was never billed. The close now also counts any turn still owed at cleanup as cut The limiter tests that check a finished socket's refund now wait for the background refund, since before Python 3.12 that task only starts once the caller yields * refactor(proxy): spell each socket close kind explicitly in the Rust limiter * fix(proxy): keep a closed socket's TPM reservation when its turns are still logging after the wait --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| litellm_completion_transformation | ||
| mcp | ||
| __init__.py | ||
| test_additional_tools.py | ||
| test_custom_tool_call.py | ||
| test_input_items_query.py | ||
| test_instructions_length.py | ||
| test_metadata_codex_callback.py | ||
| test_no_duplicate_spend_logs.py | ||
| test_null_test_fix.py | ||
| test_responses_api_bridge_flag.py | ||
| test_responses_api_lifecycle.py | ||
| test_responses_api_request_body.py | ||
| test_responses_prompt_management.py | ||
| test_responses_router_cooldown.py | ||
| test_responses_streaming_iterator.py | ||
| test_responses_supported_endpoints_passthrough.py | ||
| test_responses_utils.py | ||
| test_responses_websocket_all_providers.py | ||
| test_rust_bridge_websocket.py | ||
| test_sse_output_recovery.py | ||
| test_streaming_iterator.py | ||
| test_streaming_iterator_error_events.py | ||
| test_text_format_conversion.py | ||