fix: support Responses input in Redis semantic cache - #28274
Conversation
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
c0e4aa4 to
3d16a55
Compare
Greptile SummaryThis PR fixes
Confidence Score: 4/5Safe to merge; the fix is well-scoped and the async path already behaved this way, so the sync change is a consistency fix rather than new ground. Both the dict and object branches of litellm/caching/redis_semantic_cache.py — the text-key fallback loop in both the dict and object branches of
|
| Filename | Overview |
|---|---|
| litellm/caching/redis_semantic_cache.py | Adds _get_prompt_from_kwargs, _collect_responses_input_text, and _coerce_response_input_value to extract prompts from Responses API input alongside existing messages support; replaces four hard-coded messages extractions in set/get (sync+async) with the new helper. Minor edge case in text-key fallback logic. |
| litellm/caching/caching.py | Removes local messages extraction in sync get_cache and passes full **kwargs to backend cache, making it consistent with the already-existing async path behavior. |
| tests/test_litellm/caching/test_redis_semantic_cache.py | Adds 8 new unit tests covering sync/async set+get with string input, structured Responses input flattening, prompt extraction edge cases (model objects, None, whitespace), and the Cache wrapper passthrough. All mocked, no real network calls. |
| tests/test_litellm/interactions/test_openapi_compliance.py | Adds "budget_exceeded" to the expected Responses API status enum in the OpenAPI compliance assertion. |
Reviews (1): Last reviewed commit: "test: include budget exceeded interactio..." | Re-trigger Greptile
|
🤖 litellm-agent: Auto-merge skipped — the staging branch Please rebase your branch onto |
81002f7 to
716e17f
Compare
|
May I ask why this was closed? |
|
@balcsida The branch was deleted when cleaning old branches up. Can you use the latest internal staging as base and recreate the PR? sorry for the trouble. |
|
Fair enough, @Sameerlite |
Relevant issues
Fixes #28272
Linear ticket
N/A
Pre-Submission checklist
Screenshots / Proof of Fix
Before this change, RedisSemanticCache only extracted prompts from messages. Responses API calls pass input instead, so RedisVL store/check were skipped and the RediSearch index stayed empty.
Validation run locally:
I also attempted the broader caching test directory, but the local environment is missing optional dependencies for unrelated Azure/S3 cache tests (
azure,boto3).Type
Bug Fix
Test
Changes