Skip to content
This repository was archived by the owner on Mar 2, 2026. It is now read-only.

fix: memory_recall now finds tree-indexed memories#585

Merged
zonk1024 merged 1 commit intomainfrom
fix/memory-recall-source-sections
Feb 28, 2026
Merged

fix: memory_recall now finds tree-indexed memories#585
zonk1024 merged 1 commit intomainfrom
fix/memory-recall-source-sections

Conversation

@zonk1024
Copy link
Contributor

Problem

memory_recall returned 0 results despite 84 stored memories in the database.

Root Cause

Tree-indexed sources are returned from knowledge_search as type='source_section' (not type='source'). The parent source ID is in a source_id field rather than id. memory_recall only matched type='source', so all tree-indexed memories were invisible.

Fix

Match both source and source_section types in the collection loop, using the appropriate ID field for each.

Testing

  • 1716 passed, 0 failed
  • Verified locally: memory_recall('worker timeout') now returns the stored lesson (was returning 0 results)

memory_recall only matched type='source' results from knowledge_search,
but tree-indexed sources return as type='source_section' with the parent
source ID in a 'source_id' field. This meant all 84 stored memories were
invisible to recall.

Now matches both 'source' and 'source_section' types, using the correct
parent source ID for metadata lookups.
Copilot AI review requested due to automatic review settings February 28, 2026 21:21
@zonk1024 zonk1024 merged commit 45b6532 into main Feb 28, 2026
5 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes memory_recall returning no memories when retrieval returns tree-indexed results as type="source_section" (with the parent source ID in source_id), ensuring those memories are now discoverable.

Changes:

  • Update memory_recall to collect IDs from both source and source_section result types.
  • Deduplicate collected source IDs before batch-fetching metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +152 to +156
item_type = item.get("type")
if item_type == "source":
sid = item.get("id")
elif item_type == "source_section":
sid = item.get("source_id")
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change adds support for type="source_section", but the existing memory_recall tests only cover type="source". Add a unit test case where knowledge_search returns a source_section result with a source_id, and assert the handler fetches metadata for the parent source and returns a memory entry.

Copilot uses AI. Check for mistakes.
Comment on lines +159 to +161
if sid and sid not in source_items:
source_ids.append(sid)
source_items[sid] = item
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sid is coming from knowledge_search results and is a string (see retrieval serializing IDs), but later source_metadata is keyed by row["id"] from psycopg2 which may be a uuid.UUID in some environments. That mismatch would make source_metadata.get(source_id) miss and silently drop otherwise-valid memories. Normalize the DB row key (e.g., str(row["id"])) to match sid (or normalize sid to UUID consistently).

Copilot uses AI. Check for mistakes.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants