fix(agent): 解决内存文件读取编码问题

- 为文件读取操作明确指定 UTF-8 编码
- 防止因默认编码导致的字符读取错误
- 确保跨平台环境下的文件内容一致性
This commit is contained in:
developer-wlj
2026-03-27 11:52:07 +08:00
committed by jxxghp
parent a25c709927
commit d8c86069f2
+1 -1
View File
@@ -335,7 +335,7 @@ class MemoryMiddleware(AgentMiddleware[MemoryState, ContextT, ResponseT]): # no
MAX_MEMORY_FILE_SIZE, MAX_MEMORY_FILE_SIZE,
) )
continue continue
contents[path] = await file_path.read_text() contents[path] = await file_path.read_text(encoding="utf-8")
logger.debug("Loaded memory from: %s", path) logger.debug("Loaded memory from: %s", path)
except Exception as e: except Exception as e:
logger.warning("Failed to read memory file %s: %s", path, e) logger.warning("Failed to read memory file %s: %s", path, e)