Skip to content

fix memory panel pagination and skill usage analytics - #726

Merged
hijzy merged 1 commit into
MemTensor:1.2.401from
hijzy:1.2.401
Oct 23, 2026
Merged

hijzy merged 1 commit into
MemTensor:1.2.401from
hijzy:1.2.401

Conversation

@hijzy

@hijzy hijzy commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@hijzy
hijzy requested a review from ZongYue99 as a code owner October 23, 2026 07:43
@hijzy
hijzy merged commit ffe9f35 into MemTensor:1.2.401 Oct 23, 2026
6 of 8 checks passed
@hijzy
hijzy deleted the 1.2.401 branch October 23, 2026 07:53
@Memtensor-AI

Copy link
Copy Markdown
Collaborator

πŸ€– Open Code Review

Target: PR #726
Task: 351be3e046a117e0
Base: 1.2.401
Head: 1.2.401

πŸ” OpenCodeReview found 5 issue(s) in this PR.


1. Memory/src/service/read-model/panel-read.ts (L410-L412)

rerelyUsedSkills now issues two extra queries that can each pull 10k full rows (listRecallEvents uses SELECT *, so query, request_json and dropped_json are parsed for every row), and then discards everything outside the 7-day window in JS. Because LIMIT is applied before the date filter, a busy instance silently truncates the window and reports a low count.

Pass the oldest date key (dates[0]) as a SQL-level lower bound (and add created_at indexes) so the database can bound the range instead of relying on a row cap.


2. Memory/src/storage/repositories.ts (L3107-L3111)

This read is used for an aggregate count, but SELECT * hydrates the whole RecallEventRecord (query text, request payload, dropped list) for up to 10k rows. recall_events only has idx_recall_events_session_created (leading session_id), so ORDER BY created_at DESC without a session filter requires a full scan plus sort.

For the panel path, consider a narrow aggregate read that projects only created_at and hit_memory_ids_json, plus a created_at index. If this generic method is kept, an optional since clause would let callers push the time window into SQL.


3. Memory/src/service/read-model/panel-read.ts (L712)

Summing both signals double-counts a single use: whenever the skill-invoke path also records a recall event (retrievalMode: "skill_invoke"), the same skill contributes once through invoked and again through recalled. It also treats a skill that merely appeared in memory_search results β€” never applied β€” as a "use".

When the label is "skill uses", consider counting skill trials only, or deduplicate per skill per turn/session instead of adding the two totals.


4. Memory/src/service/read-model/panel.ts (L103)

panelSourceForStatsRow never reads id; making it required on MemoryStatsRow forces this caller to pass a field the helper ignores. Narrowing the parameter keeps the projection honest while the aggregate read model still gets id where it is actually needed.

πŸ’‘ Suggested Change

Before:

    id: memory.id,

After:

function panelSourceForStatsRow(memory: Omit<MemoryStatsRow, "id">): string {

5. Memory/src/service/read-model/panel-read.ts (L410-L413)

The if (input.activeSkillIds.size === 0) return 0; guard inside panelActivatedSkillUseCount cannot save any work: both queries are evaluated as arguments before the helper is entered, so an installation with zero activated skills still pays for two 10k-row reads on every analytics refresh. Short-circuit before the calls (e.g. only build the recentlyUsedSkills input when activeSkillIds.size > 0, otherwise pass empty arrays) so the guard actually avoids the queries.

πŸ’‘ Suggested Change

Before:

    const recentlyUsedSkills = panelActivatedSkillUseCount({
      activeSkillIds,
      recallEvents: this.deps.repos.runtime.listRecallEvents({ limit: PANEL_USAGE_EVENT_LIMIT }),
      skillTrials: this.deps.repos.runtime.listSkillTrials({ limit: PANEL_USAGE_EVENT_LIMIT }),

After:

    const recentlyUsedSkills = activeSkillIds.size === 0
      ? 0
      : panelActivatedSkillUseCount({
          activeSkillIds,
          recallEvents: this.deps.repos.runtime.listRecallEvents({ limit: PANEL_USAGE_EVENT_LIMIT }),
          skillTrials: this.deps.repos.runtime.listSkillTrials({ limit: PANEL_USAGE_EVENT_LIMIT }),
          dates,
          timeZone
        });

Generated by cloud-assistant via Open Code Review.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants