Backtestslitellmrun-20261018-182052#40846
[Bug]: Completed /v1/responses requests retain max_parallel_requests slots during deferred logging
Our patch was judged better than the merged fix.
In this judgment, Patch A = our agent, Patch B = the merged fix.
Both patches fix the root cause the same way: they release the stashed max_parallel_requests acquisition in async_post_call_success_hook, which the proxy awaits before returning a non-streaming response, and both guard against the deferred async_log_success_event releasing the same slot a second time. The independent tests pass on both. The difference is in how the double-release is prevented and in scope. Patch A detaches the acquisition from the stash before the first await, so under asyncio's single-threaded model the post-call hook and the deferred callback cannot both see a live slot; it needs no new state and touches only the two relevant sites. Patch B introduces an asyncio.Lock field on the per-request RequestRateLimiterStash dataclass and reroutes six release sites (pre-call rejections, failure event, disconnect, post-call failure) through the new locked helper. That refactor is consistent but goes well beyond the issue's ask and adds a synchronization primitive to a dataclass that is created per request, which is extra surface for little gain given the lockless pattern suffices. On tests, Patch A's first test runs the real ProxyLogging callback ordering with a slow logger ahead of the limiter, verifies the slot is free while logging is blocked, admits a follow-up request in a separate request context, and then verifies the late success event does not free the follow-up's slot; its second test forces a genuine interleave of the two releasers. Patch B's tests cover the same ground reasonably (including a Redis-failure concurrent release) but with more reliance on internal attributes like parallel_release_script. Patch A also documents why the post-call hook now owns the release. Patch B's one advantage is that keeping parallel_slot set until the release succeeds preserves retry-on-failure, but the release path already has an in-memory fallback, so this is marginal. A's narrower, lockless fix with strong tests is the better change.
Four judges ruled on this ticket in parallel, and the verdict comes from counting their votes. Each saw the issue and the two patches, labelled A and B in random order (two of them saw ours as A), with issue links and version numbers removed. Where tests could check the fix, they also saw the results of tests a separate agent wrote for the issue, run on both patches. None was told which patch was ours. The reasoning above is one judge's, shown verbatim.
Solve
46m 58s
Wall-clock time in the container
Full test suite
No new failures
1,799 passed · 1 skipped · 1,800 total
Contamination audit
Clean
No sign the agent saw the real fix
Patch size
222vs 199 merged
Changed lines, ours vs merged
The issue
View on GitHubCheck for existing issues
- I have searched the existing issues and checked that my issue is not a duplicate.
What happened?
A completed non-streaming /v1/responses request can continue occupying its max_parallel_requests slot until asynchronous success logging finishes. With a virtual key limited to one parallel request, the first request returns 200, but an identical request sent immediately afterward can incorrectly receive 429. The next request succeeds once success logging completes.
The slot should be released before the completed response is returned to the caller. Slow logging integrations should not extend the request's concurrency lifetime.
This is related to #27955, but differs from the persistent slot leaks reported there: in this case the slot is eventually released, just too late. A proposed fix is in #40843.
User Flow
Before a fix: a developer using the Responses API receives a false rate-limit response after the previous request has already completed.
- The proxy administrator creates a virtual key with
max_parallel_requests: 1. - The developer sends a non-streaming
POST http://localhost:4000/v1/responsesrequest. - The completed request returns
200. - The developer immediately sends the same request again and receives
429. - After success logging finishes, the developer retries and receives
200.
After a fix: the completed request releases its slot before returning, so the next request is admitted immediately.
- The proxy administrator creates a virtual key with
max_parallel_requests: 1. - The developer sends the same non-streaming
POST http://localhost:4000/v1/responsesrequest. - The completed request returns
200. - The developer immediately sends the same request again and also receives
200. - Later requests continue receiving
200after success logging finishes.
Proof the bug occurs
The issue was reproduced against a real OpenAI-compatible Responses deployment with a local LiteLLM proxy, a virtual key limited to one parallel request, and a custom success logger that takes three seconds to complete. Secrets and provider-specific endpoint values are represented by environment variables below.
slow_callback.py:
import asyncio
from litellm.integrations.custom_logger import CustomLogger
class SlowSuccessLogger(CustomLogger):
async def async_log_success_event(
self, kwargs, response_obj, start_time, end_time
) -> None:
await asyncio.sleep(3)
slow_success_logger = SlowSuccessLogger()
Relevant config.yaml:
model_list:
- model_name: responses-test
litellm_params:
model: openai/<model-name>
api_base: os.environ/OPENAI_API_BASE
api_key: os.environ/OPENAI_API_KEY
litellm_settings:
callbacks: slow_callback.slow_success_logger
general_settings:
master_key: os.environ/LITELLM_MASTER_KEY
Version tested before the fix:
litellm_internal_staging at f90b5cad8a973eb8ddd94b3c8381c4ed83bba9f2
The same non-streaming request was sent three times: once initially, once immediately after the first response, and once after the three-second logging delay.
first=200
immediate_next=429
after_logging=200
With the proposed fix from #40843 applied:
first=200
immediate_next=200
after_logging=200
What part of LiteLLM is this about?
Proxy
What LiteLLM version are you on ?
litellm_internal_staging at f90b5cad8a973eb8ddd94b3c8381c4ed83bba9f2
Twitter / LinkedIn details
_No response_
The two patches
litellm/proxy/hooks/parallel_request_limiter_v3.pyindex f72720b472..233f314377 100644@@ -4523,14 +4523,10 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger): try: verbose_proxy_logger.debug("INSIDE parallel request limiter ASYNC SUCCESS LOGGING") - stash: Final = get_request_stash_for_call(_call_id_from_callback_kwargs(kwargs))- acquisition: Final = stash.parallel_slot if stash is not None else None- if stash is not None and acquisition is not None:- await self._release_parallel_request_slots(- acquisition=acquisition,- parent_otel_span=litellm_parent_otel_span,- )- stash.parallel_slot = None+ await self._release_stashed_parallel_slot(+ stash=get_request_stash_for_call(_call_id_from_callback_kwargs(kwargs)),+ parent_otel_span=litellm_parent_otel_span,+ ) pipeline_operations: Final = self._build_success_event_pipeline_operations( kwargs=kwargs,@@ -4755,8 +4751,10 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger): ``async_pre_call_hook`` acquired, for a request that ended without either logging callback firing. - The slot is normally released by ``async_log_success_event`` (natural- stream completion) or ``async_log_failure_event`` (LLM error). When a+ The slot is normally released by ``async_post_call_success_hook``+ (completed non-streaming response), ``async_log_success_event``+ (natural stream completion) or ``async_log_failure_event`` (LLM+ error). When a client cancels a stream mid-flight, the cancellation surfaces as ``asyncio.CancelledError`` / ``GeneratorExit`` and neither callback runs, so without this the slot leaks per cancelled stream until its@@ -4774,10 +4772,52 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger): ) stash.parallel_slot = None + async def _release_stashed_parallel_slot(+ self,+ stash: RequestRateLimiterStash | None,+ parent_otel_span: Span | None,+ ) -> None:+ """+ Release the stashed max_parallel_requests acquisition, if any. The+ acquisition is detached from the stash before the first await so that+ concurrent releasers (the post-call success hook and the deferred+ success logging callback) cannot both release it — a double release+ would double-decrement under the in-memory integer-mirror fallback.+ """+ if stash is None:+ return+ acquisition: Final = stash.parallel_slot+ if acquisition is None:+ return+ stash.parallel_slot = None+ await self._release_parallel_request_slots(+ acquisition=acquisition,+ parent_otel_span=parent_otel_span,+ )+ async def async_post_call_success_hook(self, data: dict, user_api_key_dict: UserAPIKeyAuth, response): """- Post-call hook to update rate limit headers in the response.+ Post-call hook to update rate limit headers in the response and+ release the request's max_parallel_requests slot.++ The proxy awaits this hook before returning a completed non-streaming+ response, so releasing here keeps the slot's lifetime bounded by the+ request itself. Success logging (``async_log_success_event``) runs+ asynchronously after the response is returned and can be delayed by+ slow logging integrations; relying on it alone would make the next+ request on a ``max_parallel_requests: 1`` key fail with a 429 even+ though the previous request already completed. Streaming responses+ return before this hook runs and keep their slot until the stream+ ends. """+ try:+ await self._release_stashed_parallel_slot(+ stash=get_request_stash_for_call(_call_id_from_callback_kwargs(data)),+ parent_otel_span=user_api_key_dict.parent_otel_span,+ )+ except Exception as e: # noqa: BLE001 # slot release must never fail the completed response+ verbose_proxy_logger.exception("Error releasing parallel request slot in post-call hook: %s", e)+ try: stash: Final = get_request_stash() litellm_proxy_rate_limit_response: Final = stash.rate_limit_response if stash is not None else Nonetests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.pyindex 8d7ab89f35..25f753b1f5 100644@@ -4254,6 +4254,166 @@ async def test_success_event_releases_parallel_slot_v3(monkeypatch): ) +@pytest.mark.asyncio+async def test_post_call_success_hook_releases_parallel_slot_before_deferred_logging_v3():+ """+ A completed non-streaming /v1/responses request must release its+ max_parallel_requests slot before the proxy returns the response, not+ when deferred success logging eventually runs. With a slow success+ logger ahead of the limiter, the next request on a+ ``max_parallel_requests: 1`` key must be admitted immediately instead of+ receiving a 429, and the late success event must not release again.+ """+ from litellm.integrations.custom_logger import CustomLogger++ _api_key = hash_token("sk-12345")+ local_cache = DualCache()+ handler = _PROXY_MaxParallelRequestsHandler(+ internal_usage_cache=InternalUsageCache(local_cache)+ )+ user_api_key_dict = UserAPIKeyAuth(api_key=_api_key, max_parallel_requests=1)+ counter_key = f"{{api_key:{_api_key}}}:max_parallel_requests"++ logging_started = asyncio.Event()+ allow_logging_to_finish = asyncio.Event()+ limiter_success_event_ran = asyncio.Event()++ class _SlowSuccessLogger(CustomLogger):+ async def async_log_success_event(self, kwargs, response_obj, start_time, end_time):+ logging_started.set()+ await allow_logging_to_finish.wait()++ original_success_event = handler.async_log_success_event++ async def _tracking_success_event(kwargs, response_obj, start_time, end_time):+ await original_success_event(kwargs, response_obj, start_time, end_time)+ limiter_success_event_ran.set()++ handler.async_log_success_event = _tracking_success_event # type: ignore[method-assign]++ with _override_litellm_callbacks([_SlowSuccessLogger(), handler]):+ proxy_logging_obj = ProxyLogging(user_api_key_cache=DualCache())+ call_id = "responses-call-1"+ request_data: Dict[str, Any] = {+ "model": "gpt-4o",+ "input": "hi",+ "litellm_call_id": call_id,+ }+ await handler.async_pre_call_hook(+ user_api_key_dict=user_api_key_dict,+ cache=local_cache,+ data=request_data,+ call_type="aresponses",+ )+ assert handler._gauge_in_flight_from_cache_value(+ await local_cache.async_get_cache(key=counter_key)+ ) == 1++ response = await litellm.aresponses(+ model="gpt-4o",+ input="hi",+ mock_response="hello",+ litellm_call_id=call_id,+ )+ await proxy_logging_obj.post_call_success_hook(+ data=request_data,+ user_api_key_dict=user_api_key_dict,+ response=response,+ )++ # The response is ready to return while success logging is still+ # blocked: the slot must already be free.+ await asyncio.wait_for(logging_started.wait(), timeout=10)+ assert not limiter_success_event_ran.is_set()+ assert handler._gauge_in_flight_from_cache_value(+ await local_cache.async_get_cache(key=counter_key)+ ) == 0++ # Immediate follow-up request on the same key is admitted (no 429).+ # It runs in its own request context, like a separate proxy request.+ async def _follow_up_request() -> None:+ _request_stash.set(None)+ await handler.async_pre_call_hook(+ user_api_key_dict=user_api_key_dict,+ cache=local_cache,+ data={"model": "gpt-4o", "input": "hi", "litellm_call_id": "responses-call-2"},+ call_type="aresponses",+ )++ await asyncio.create_task(_follow_up_request())+ assert handler._gauge_in_flight_from_cache_value(+ await local_cache.async_get_cache(key=counter_key)+ ) == 1++ # The late success event of the first request must not free the+ # follow-up request's slot.+ allow_logging_to_finish.set()+ await asyncio.wait_for(limiter_success_event_ran.wait(), timeout=10)+ assert handler._gauge_in_flight_from_cache_value(+ await local_cache.async_get_cache(key=counter_key)+ ) == 1+++@pytest.mark.asyncio+async def test_concurrent_post_call_and_success_event_release_parallel_slot_once_v3():+ """+ The post-call success hook and the deferred success logging callback can+ race on the same stashed acquisition. Under the in-memory integer-mirror+ fallback a double release would free another in-flight request's+ capacity, so exactly one of them may decrement the gauge.+ """+ _api_key = hash_token("sk-12345")+ local_cache = DualCache()+ handler = _PROXY_MaxParallelRequestsHandler(+ internal_usage_cache=InternalUsageCache(local_cache)+ )+ user_api_key_dict = UserAPIKeyAuth(api_key=_api_key, max_parallel_requests=5)+ counter_key = f"{{api_key:{_api_key}}}:max_parallel_requests"++ request_data: Dict[str, Any] = {"model": "gpt-4o", "litellm_call_id": "call-race"}+ await handler.async_pre_call_hook(+ user_api_key_dict=user_api_key_dict,+ cache=local_cache,+ data=request_data,+ call_type="aresponses",+ )+ # Simulate the Redis-mirrored integer count: this request plus one other+ # request in flight elsewhere.+ await local_cache.async_set_cache(key=counter_key, value=2)++ # Yield inside the release so both releasers genuinely interleave; the+ # in-memory release otherwise never suspends and the race never happens.+ original_release = handler._release_parallel_request_slots++ async def _yielding_release(*args, **kwargs):+ await asyncio.sleep(0)+ return await original_release(*args, **kwargs)++ handler._release_parallel_request_slots = _yielding_release # type: ignore[method-assign]++ await asyncio.gather(+ handler.async_post_call_success_hook(+ data=request_data,+ user_api_key_dict=user_api_key_dict,+ response=ModelResponse(),+ ),+ handler.async_log_success_event(+ kwargs={+ "litellm_call_id": "call-race",+ "standard_logging_object": {"metadata": {"user_api_key_hash": _api_key}},+ },+ response_obj=ModelResponse(+ usage=Usage(prompt_tokens=5, completion_tokens=5, total_tokens=10)+ ),+ start_time=datetime.now(),+ end_time=datetime.now(),+ ),+ )+ assert handler._gauge_in_flight_from_cache_value(+ await local_cache.async_get_cache(key=counter_key)+ ) == 1++ @pytest.mark.asyncio async def test_read_only_gauge_check_counts_without_acquiring_v3(): """
litellm/proxy/hooks/parallel_request_limiter_v3.pyindex f72720b4726..89826694bb6 100644@@ -531,6 +531,7 @@ class RequestRateLimiterStash: owner_litellm_call_id: str | None = None rate_limit_response: RateLimitResponse | None = None parallel_slot: ParallelSlotAcquisition | None = None+ parallel_slot_release_lock: asyncio.Lock = field(default_factory=asyncio.Lock, repr=False, compare=False) reserved_tokens: int = 0 reserved_model: str | None = None reserved_scopes: frozenset[tuple[str, str]] = field(default_factory=frozenset)@@ -1620,6 +1621,20 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger): statuses.append(self._gauge_status(gauge, in_flight + 1, "OK")) return RateLimitResponse(overall_code="OK", statuses=statuses) + async def _release_stashed_parallel_slot(+ self,+ stash: RequestRateLimiterStash | None,+ parent_otel_span: Span | None,+ ) -> None:+ if stash is None:+ return+ async with stash.parallel_slot_release_lock:+ acquisition: Final = stash.parallel_slot+ if acquisition is None:+ return+ await self._release_parallel_request_slots(acquisition, parent_otel_span)+ stash.parallel_slot = None # rebind-ok: marks this request's slot as released+ async def _release_parallel_request_slots( self, acquisition: ParallelSlotAcquisition,@@ -3379,13 +3394,7 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger): parent_otel_span=user_api_key_dict.parent_otel_span, ) stash.reservation_released = True- acquisition: Final = stash.parallel_slot- if acquisition is not None:- await self._release_parallel_request_slots(- acquisition=acquisition,- parent_otel_span=user_api_key_dict.parent_otel_span,- )- stash.parallel_slot = None+ await self._release_stashed_parallel_slot(stash, user_api_key_dict.parent_otel_span) self._handle_rate_limit_error( response=io_response, descriptors=descriptors,@@ -3700,13 +3709,7 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger): ) if tpm_response["overall_code"] == "OVER_LIMIT":- acquisition: Final = stash.parallel_slot- if acquisition is not None:- await self._release_parallel_request_slots(- acquisition=acquisition,- parent_otel_span=user_api_key_dict.parent_otel_span,- )- stash.parallel_slot = None+ await self._release_stashed_parallel_slot(stash, user_api_key_dict.parent_otel_span) self._handle_rate_limit_error( response=tpm_response, descriptors=descriptors,@@ -4524,13 +4527,7 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger): verbose_proxy_logger.debug("INSIDE parallel request limiter ASYNC SUCCESS LOGGING") stash: Final = get_request_stash_for_call(_call_id_from_callback_kwargs(kwargs))- acquisition: Final = stash.parallel_slot if stash is not None else None- if stash is not None and acquisition is not None:- await self._release_parallel_request_slots(- acquisition=acquisition,- parent_otel_span=litellm_parent_otel_span,- )- stash.parallel_slot = None+ await self._release_stashed_parallel_slot(stash, litellm_parent_otel_span) pipeline_operations: Final = self._build_success_event_pipeline_operations( kwargs=kwargs,@@ -4650,13 +4647,7 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger): pipeline_operations: Final[list[RedisPipelineIncrementOperation]] = [] stash: Final = get_request_stash_for_call(_call_id_from_callback_kwargs(kwargs))- acquisition: Final = stash.parallel_slot if stash is not None else None- if stash is not None and acquisition is not None:- await self._release_parallel_request_slots(- acquisition=acquisition,- parent_otel_span=litellm_parent_otel_span,- )- stash.parallel_slot = None+ await self._release_stashed_parallel_slot(stash, litellm_parent_otel_span) # Skip the reservation refund if async_post_call_failure_hook # already released it (proxy-level rejection that also bubbles up@@ -4764,23 +4755,23 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger): object's current max_parallel_requests configuration, which can change mid-request) decides whether there is anything to release. """- stash: Final = get_request_stash()- if stash is None or stash.parallel_slot is None:- return-- await self._release_parallel_request_slots(- acquisition=stash.parallel_slot,- parent_otel_span=None,- )- stash.parallel_slot = None+ await self._release_stashed_parallel_slot(get_request_stash(), None) async def async_post_call_success_hook(self, data: dict, user_api_key_dict: UserAPIKeyAuth, response): """- Post-call hook to update rate limit headers in the response.+ Release completed-request slots and update rate limit headers in the response. """ try:- stash: Final = get_request_stash()- litellm_proxy_rate_limit_response: Final = stash.rate_limit_response if stash is not None else None+ slot_stash: Final = get_request_stash_for_call(_call_id_from_callback_kwargs(data))+ await self._release_stashed_parallel_slot(slot_stash, user_api_key_dict.parent_otel_span)+ except Exception as e:+ verbose_proxy_logger.exception("Error releasing parallel request slot in post-call hook: %s", e)++ try:+ header_stash: Final = get_request_stash()+ litellm_proxy_rate_limit_response: Final = (+ header_stash.rate_limit_response if header_stash is not None else None+ ) if litellm_proxy_rate_limit_response is not None and response_has_hidden_params(response): additional_headers: Final = ensure_response_additional_headers(response)@@ -4848,12 +4839,7 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger): stash: Final = get_request_stash() if stash is None: return- if stash.parallel_slot is not None:- await self._release_parallel_request_slots(- acquisition=stash.parallel_slot,- parent_otel_span=user_api_key_dict.parent_otel_span,- )- stash.parallel_slot = None+ await self._release_stashed_parallel_slot(stash, user_api_key_dict.parent_otel_span) if stash.batch_enqueued_reservation is not None: await self.batch_enqueued_token_store.refund(tests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.pyindex 8d7ab89f354..85023b94207 100644@@ -7,6 +7,7 @@ import logging import os import sys import time+from collections.abc import Sequence from contextlib import contextmanager from datetime import datetime, timedelta from typing import Any, Dict, List, Optional@@ -32,6 +33,7 @@ from litellm.proxy.hooks.parallel_request_limiter_v3 import ( ) from litellm.proxy.utils import InternalUsageCache, ProxyLogging, hash_token from litellm.types.caching import RedisPipelineIncrementOperation+from litellm.types.llms.openai import ResponsesAPIResponse from litellm.types.utils import ( EmbeddingResponse, ModelResponse,@@ -4054,6 +4056,125 @@ async def _seed_max_parallel_requests_slots( ) +@pytest.mark.asyncio+async def test_completed_responses_post_call_releases_parallel_slot() -> None:+ api_key = hash_token("sk-responses-post-call")+ local_cache = DualCache()+ handler = _PROXY_MaxParallelRequestsHandler(+ internal_usage_cache=InternalUsageCache(local_cache)+ )+ user_api_key_dict = UserAPIKeyAuth(api_key=api_key, max_parallel_requests=1)+ data = {+ "model": "gpt-4o-mini",+ "input": "hello",+ "litellm_call_id": "responses-owner",+ }+ parallel_key = f"{{api_key:{api_key}}}:max_parallel_requests"++ await handler.async_pre_call_hook(+ user_api_key_dict=user_api_key_dict,+ cache=local_cache,+ data=data,+ call_type="aresponses",+ )+ assert handler._gauge_in_flight_from_cache_value(+ await local_cache.async_get_cache(key=parallel_key)+ ) == 1++ await handler.async_post_call_success_hook(+ data=data,+ user_api_key_dict=user_api_key_dict,+ response=ResponsesAPIResponse(+ id="resp_parallel_slot",+ created_at=0,+ model="gpt-4o-mini",+ object="response",+ output=[],+ status="completed",+ ),+ )+ assert handler._gauge_in_flight_from_cache_value(+ await local_cache.async_get_cache(key=parallel_key)+ ) == 0++ await handler.async_log_success_event(+ kwargs={"litellm_call_id": data["litellm_call_id"]},+ response_obj=None,+ start_time=None,+ end_time=None,+ )+ assert handler._gauge_in_flight_from_cache_value(+ await local_cache.async_get_cache(key=parallel_key)+ ) == 0+++@pytest.mark.asyncio+async def test_concurrent_success_callbacks_release_parallel_slot_once_when_redis_fails() -> None:+ from unittest.mock import AsyncMock++ api_key = hash_token("sk-concurrent-release")+ local_cache = DualCache()+ handler = _PROXY_MaxParallelRequestsHandler(+ internal_usage_cache=InternalUsageCache(local_cache)+ )+ user_api_key_dict = UserAPIKeyAuth(api_key=api_key, max_parallel_requests=2)+ call_id = "concurrent-release-owner"+ parallel_key = f"{{api_key:{api_key}}}:max_parallel_requests"+ release_started = asyncio.Event()+ allow_redis_failure = asyncio.Event()++ async def failing_release(+ keys: Sequence[str], args: Sequence[object]+ ) -> list[int]:+ release_started.set()+ await allow_redis_failure.wait()+ raise ConnectionError("redis unavailable")++ release_script = AsyncMock(side_effect=failing_release)+ handler.parallel_release_script = release_script+ await local_cache.async_set_cache(key=parallel_key, value=2, local_only=True)+ stash = get_or_create_request_stash()+ stash.owner_litellm_call_id = call_id+ stash.parallel_slot = ParallelSlotAcquisition(+ slot_id="slot-concurrent-release",+ counter_keys=[parallel_key],+ )+ data = {"litellm_call_id": call_id}++ post_call_task = asyncio.create_task(+ handler.async_post_call_success_hook(+ data=data,+ user_api_key_dict=user_api_key_dict,+ response=ResponsesAPIResponse(+ id="resp_concurrent_release",+ created_at=0,+ model="gpt-4o-mini",+ object="response",+ output=[],+ status="completed",+ ),+ )+ )+ await asyncio.wait_for(release_started.wait(), timeout=5)+ logging_task = asyncio.create_task(+ handler.async_log_success_event(+ kwargs=data,+ response_obj=None,+ start_time=None,+ end_time=None,+ )+ )+ allow_redis_failure.set()+ await asyncio.wait_for(+ asyncio.gather(post_call_task, logging_task),+ timeout=5,+ )++ assert release_script.await_count == 1+ assert await local_cache.async_get_cache(key=parallel_key) == 1+ assert stash.parallel_slot is None++ async def _build_seeded_limiter(): """Build a v3 limiter whose api-key slot registry already holds the pre-call slot.""" api_key = hash_token("sk-disconnect")