Skip to content

Commit 59285f7

Browse files
AliiiBennclaude
andcommitted
fix: parse cached_at ISO string to datetime before checking TTL
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 95ccfd6 commit 59285f7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

websearch/core/agent/response_cache.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ def get(self, query: str, count: int, model: str) -> dict[str, Any] | None:
106106
# Check TTL
107107
cached_at = metadata.get("cached_at")
108108
if cached_at:
109+
from datetime import datetime
110+
109111
from websearch.core.cache.ttl import is_expired
110112

111-
if is_expired(cached_at, self.ttl):
113+
# Parse ISO string back to datetime
114+
cached_at_dt = datetime.fromisoformat(cached_at)
115+
if is_expired(cached_at_dt, self.ttl):
112116
return None
113117

114118
response = json.loads(response_path.read_text())
@@ -271,9 +275,13 @@ def get(self, url: str, prompt: str) -> dict[str, Any] | None:
271275
# Check TTL
272276
cached_at = metadata.get("cached_at")
273277
if cached_at:
278+
from datetime import datetime
279+
274280
from websearch.core.cache.ttl import is_expired
275281

276-
if is_expired(cached_at, self.ttl):
282+
# Parse ISO string back to datetime
283+
cached_at_dt = datetime.fromisoformat(cached_at)
284+
if is_expired(cached_at_dt, self.ttl):
277285
return None
278286

279287
response = json.loads(response_path.read_text())

0 commit comments

Comments
 (0)