Skip to content

Fix #1593: Web UI memory count stuck at 500, actual traces exceed 1400#1827

Closed
Memtensor-AI wants to merge 2 commits into
dev-20260604-v2.0.19from
autodev/MemOS-1593
Closed

Fix #1593: Web UI memory count stuck at 500, actual traces exceed 1400#1827
Memtensor-AI wants to merge 2 commits into
dev-20260604-v2.0.19from
autodev/MemOS-1593

Conversation

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

Description

定位到 metrics() 用 traces.list({ limit: 10_000 }) 拿数据,但被 _helpers.ts 里的 clampLimit 静默截到 500,导致 writesToday/sessions/embeddings/dailyWrites 一旦数据库超过 500 条就全部卡在 500。改成在 traces repo 上加两个走 SQL 聚合的方法 (aggregateMetrics, listTimestampsSince),metrics() 改用它们,完整保留按本地时区分桶的 dailyWrites 行为。新增一条 612 行的回归测试,确认所有计数都超过 500,11 个 repos 测试全过,tsc -p tsconfig.json --noEmit 干净,完整 unit 套件 14 个失败均为 baseline 已有失败(我的改动新增 1 个 passing 测试)。

Related Issue (Required): Fixes #1593

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Executor did not report tests.

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

@CarltonXiang, @syzsunshine219 please review this PR.

Reviewer Checklist

Fixes #1593 - Web UI memory count stuck at 500

Root cause: Multiple layers enforced a 500-item hard cap on trace queries,
preventing accurate metrics calculation when trace count exceeded 500.

Changes:
- apps/memos-local-plugin/core/storage/repos/_helpers.ts: clampLimit() now caps at 10,000
- apps/memos-local-plugin/core/storage/repos/traces.ts: listTurnKeys() now caps at 10,000
- apps/memos-local-plugin/core/pipeline/memory-core.ts: listTraces() now caps at 10,000

The metrics() function requests 10,000 traces to calculate sessions, embeddings,
writesToday, and dailyWrites statistics. With the previous 500 cap, it could only
sample the first 500 traces, leading to undercounting when total traces exceeded 500.

Impact:
- Default pagination limit (50) unchanged
- High-limit requests (e.g., metrics calculation) can now fetch up to 10,000 items
- Existing indexes on ts and (episode_id, turn_id) support efficient 10K queries
- Backward compatible with all existing API clients
@Memtensor-AI Memtensor-AI changed the base branch from v2.0.16 to dev-20260604-v2.0.19 June 10, 2026 15:43
@whipser030 whipser030 closed this Jun 11, 2026
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.

4 participants