Skip to content

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

@muxiaomu001

Description

@muxiaomu001

Bug Description

During reindex (via /api/v1/content/reindex), all memory files under viking://user/memories/ and viking://agent/memories/ are incorrectly tagged with context_type = "resource" instead of "memory".

This causes downstream consumers (e.g. OpenClaw's auto-recall plugin) that filter by context_type == "memory" to miss all reindexed memories.

Root Cause

In openviking/utils/summarizer.py (line ~61), the URI check uses a prefix that doesn't match actual memory paths:

# Current (broken)
if uri.startswith("viking://memory/"):
    context_type = "memory"
elif uri.startswith("viking://agent/skills/"):
    context_type = "skill"

Actual memory URIs look like:

  • viking://user/memories/entities/mem_xxx.md
  • viking://agent/<id>/memories/cases/mem_xxx.md

None of these start with viking://memory/, so they all fall through to the default "resource".

Fix

Use substring matching consistent with core/directories.py:get_context_type_for_uri():

# Fixed
if "/memories" in uri:
    context_type = "memory"
elif "/skills" in uri:
    context_type = "skill"

Note: core/directories.py already has the correct logic ("/memories" in uri). The summarizer should match.

Impact

  • ov find works fine (no type filter)
  • OpenClaw auto-recall (context_type == "memory") misses all reindexed memories
  • New memories captured via auto-capture are unaffected (different code path)

Versions Affected

Confirmed in 0.2.9 and 0.2.13.

Workaround

sed -i 's|if uri.startswith("viking://memory/")|if "/memories" in uri|' \
  $(python3 -c "import openviking; print(openviking.__path__[0])")/utils/summarizer.py
sed -i 's|elif uri.startswith("viking://agent/skills/")|elif "/skills" in uri|' \
  $(python3 -c "import openviking; print(openviking.__path__[0])")/utils/summarizer.py

Then re-run reindex:

curl -X POST http://127.0.0.1:1933/api/v1/content/reindex \
  -H "Content-Type: application/json" \
  -d '{"uri": "viking://", "regenerate": true, "wait": false}'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions