Skip to content

fix(summarizer): use correct URI matching for memory context_type during reindex#1155

Merged
qin-ctx merged 1 commit intovolcengine:mainfrom
deepakdevp:fix/summarizer-context-type-classification
Apr 2, 2026
Merged

fix(summarizer): use correct URI matching for memory context_type during reindex#1155
qin-ctx merged 1 commit intovolcengine:mainfrom
deepakdevp:fix/summarizer-context-type-classification

Conversation

@deepakdevp
Copy link
Copy Markdown
Contributor

Summary

  • Replace broken uri.startswith("viking://memory/") prefix check in summarizer.py with a call to the existing get_context_type_for_uri() from core/directories.py
  • The old prefix never matched real memory URIs (viking://user/{space}/memories/...), causing all memories to be misclassified as context_type="resource" during reindex
  • This broke OpenClaw auto-recall which filters context_type == "memory"

Root Cause

summarizer.py:61 checked uri.startswith("viking://memory/") but actual memory URIs use the pattern viking://user/{space}/memories/... or viking://agent/{space}/memories/... — the prefix never matches.

The correct logic already existed in core/directories.py:get_context_type_for_uri() using "/memories" in uri. The fix simply wires it up.

Changes

  • openviking/utils/summarizer.py: Replace 4-line inline check with 1-line call to get_context_type_for_uri(uri)
  • tests/unit/test_summarizer_context_type.py: 9 tests covering all URI types + regression test for the old broken pattern

Test plan

  • 9 new tests pass: user memory, agent memory, profile, preferences, skill, resource, session, unknown, regression
  • 58 existing test_context.py tests pass (no regression)
  • Verified no other startswith("viking://memory") patterns remain in codebase

Fixes #1060

…assification during reindex

The summarizer used uri.startswith("viking://memory/") to detect memory
URIs, but actual memory URIs are viking://user/{space}/memories/... and
viking://agent/{space}/memories/... — the prefix never matched, causing
all memories to be classified as context_type="resource" during reindex.

Replace the broken inline prefix check with a call to the existing
get_context_type_for_uri() from core/directories.py, which correctly
uses substring matching ("/memories" in uri) and handles all URI types
including session URIs.

Fixes volcengine#1060
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Failed to generate code suggestions for PR

@qin-ctx qin-ctx requested a review from zhoujh01 April 1, 2026 11:30
@qin-ctx qin-ctx merged commit 3d0c1f5 into volcengine:main Apr 2, 2026
10 of 11 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Bug: summarizer.py context_type misclassifies memories as resources during reindex

3 participants