Skip to content

fix(harness): configurable memory-ledger timezone (#3433) - #3718

Open
aiyili wants to merge 1 commit into
agentscope-ai:mainfrom
aiyili:fix/memory-ledger-zone
Open

aiyili wants to merge 1 commit into
agentscope-ai:mainfrom
aiyili:fix/memory-ledger-zone

Conversation

@aiyili

@aiyili aiyili commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #3433

Problem

The daily memory ledger filename and flush timestamps use LocalDate.now() (JVM default zone). When the host zone differs from the zone users think in — e.g. an agent deployed in a UTC container serving users in UTC+8 — memories are filed under the wrong day, and the flush timestamp renders in a zone-less UTC string that doesn't match the ledger date.

Fix

  • MemoryFlushManager gains a ledgerZone field and a 4-arg constructor; default remains ZoneId.systemDefault() (no behavior change for existing callers).
  • flushMemories and writeMemoryFiles derive the ledger date via LocalDate.now(ledgerZone).
  • The flush timestamp now renders via Instant.now().atZone(ledgerZone) so it carries the same zone context as the ledger date it sits under.

Note: this intentionally does NOT switch the default to UTC — the ledger date is user-facing, so the right default is the deployment's chosen zone, made explicit and configurable rather than ambient. An end-to-end zone test requires a clock seam in MemoryFlushManager; that seam is small and can land as a follow-up if maintainers want deterministic date-boundary coverage.

daily ledger 文件名与 flush 时间戳用 LocalDate.now()(JVM 默认时区):
宿主时区与用户思考时区不一致时(如 UTC 容器服务中国用户),记忆被
归档到错误的日期。

- MemoryFlushManager 新增 ledgerZone 字段与 4 参构造器,默认
  systemDefault 保持既有行为;flushMemories 与 writeMemoryFiles 的
  账本日期改用 LocalDate.now(ledgerZone)
- flush 时间戳从 Instant.toString()(恒 UTC,无时区上下文)改为
  atZone(ledgerZone) 呈现,与账本日期一致

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 短期记忆Memory Flush 时间格式如何修改默认不是utc时间 — 2026-10-07T08:15:40.992228Z

1 participant