Fix #1593: Web UI memory count stuck at 500, actual traces exceed 1400#1827
Closed
Memtensor-AI wants to merge 2 commits into
Closed
Fix #1593: Web UI memory count stuck at 500, actual traces exceed 1400#1827Memtensor-AI wants to merge 2 commits into
Memtensor-AI wants to merge 2 commits into
Conversation
42e1885 to
d90c41a
Compare
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
How Has This Been Tested?
Executor did not report tests.
Checklist
@CarltonXiang, @syzsunshine219 please review this PR.
Reviewer Checklist