mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-28 00:00:38 +00:00
* fix(proxy): send x-litellm-cache-key on non-streaming /v1/messages cache hits A non-streaming /v1/messages response cache hit comes back as a plain dict with no hidden params, so the cache key never reached the response headers. When a confirmed hit leaves the key out, the proxy now sends the exact key the lookup recorded on the logging object. A key the response already carries still wins, and other endpoints are unchanged. Fixes #52585 * fix(proxy): read the recorded preset cache key through a typed Logging accessor Reading the untyped Logging.litellm_params directly added unknown-type diagnostics. Logging.get_preset_cache_key returns the recorded key as str | None from the typed params view, with the same behavior. The cache header test router now sets cache_responses=True like the proxy does once its cache exists. A default Router passes caching=False on every call, so repeats never read the cache. * test(proxy): send the /v1/messages cache header tests through an injected client The native Rust Anthropic transport bypasses respx, so the cache header tests reached the real API. A proxy pre-call hook now hands each request an AsyncHTTPHandler over httpx.MockTransport, which transport_handler sends through, and the scripted upstream records what the proxy sent. The fixture closes the client and awaits pending cache writes and logging. * test(proxy): count provider dispatches in the /v1/messages cache header tests Native Anthropic Messages is Rust-required, so no injected client or respx route could keep those calls off the network. The fixture now uses a deployment whose /v1/messages target runs on Python and replaces anthropic_messages_handler with a counting stand-in, as test_response_cache.py does. The proxy, Router, response cache and header and body processing still run for real, and the dispatch count shows whether a request was served from the cache. * test(proxy): keep the cache header tests' fake client connected until teardown The fake ASGI receive returned the same http.request on every call, so the first-chunk disconnect watcher on a streamed reply never yielded and the streaming cases spun. The cache tests now pass an asyncio.Event. Their receive hands over the body once, then waits on that event and reports http.disconnect. The fixture sets it in a finally. Existing callers of _messages_request that pass no event behave as before. --------- Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| test_answered_status.py | ||
| test_claude_code_marketplace.py | ||
| test_claude_code_skill_access.py | ||
| test_endpoints.py | ||
| test_gateway_endpoints.py | ||
| test_skill_upload_archive.py | ||
| test_skills_endpoints.py | ||
| test_streaming_model_restamp.py | ||