diff --git a/kaiwu/knowledge/doc_reader.py b/kaiwu/knowledge/doc_reader.py index 7f85014..3af4541 100644 --- a/kaiwu/knowledge/doc_reader.py +++ b/kaiwu/knowledge/doc_reader.py @@ -113,7 +113,7 @@ class DocReader: return result def _read_file(self, path: Path) -> list[str]: - key = str(path) + key = str(path.resolve()) if key in self._cache: return self._cache[key] diff --git a/kaiwu/tests/test_p1_features.py b/kaiwu/tests/test_p1_features.py index b142cf8..73a93b2 100644 --- a/kaiwu/tests/test_p1_features.py +++ b/kaiwu/tests/test_p1_features.py @@ -349,13 +349,14 @@ Connection pooling is configured in src/db/pool.py. def test_cache(self): from kaiwu.knowledge.doc_reader import DocReader + from pathlib import Path with tempfile.TemporaryDirectory() as d: with open(os.path.join(d, "doc.md"), "w", encoding="utf-8") as f: f.write("This is a test document with enough content to be a paragraph.\n") reader = DocReader(d) reader.find_relevant("test") - # Second call should use cache - assert str(os.path.join(d, "doc.md")) in reader._cache + # Second call should use cache (use resolved path for comparison) + assert str(Path(d, "doc.md").resolve()) in reader._cache # ── PatternMd.count_similar_failures ───────────────────────