Fix prompt caching middleware missing wrap/unwrap round-trip (#3666)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bill Easton 2026-03-27 20:42:09 -05:00 committed by GitHub
commit 2491993327
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -480,14 +480,15 @@ class ResponseCachingMiddleware(Middleware):
return cached_value.unwrap()
value: PromptResult = await call_next(context=context)
cached_value = CachablePromptResult.wrap(value)
await self._get_prompt_cache.put(
key=cache_key,
value=CachablePromptResult.wrap(value),
value=cached_value,
ttl=self._get_prompt_settings.get("ttl", ONE_HOUR_IN_SECONDS),
)
return value
return cached_value.unwrap()
def _matches_tool_cache_settings(self, tool_name: str) -> bool:
"""Check if the tool matches the cache settings for tool calls."""