Repository navigation
Python: give memory topic files an injective filename stem - #9724
Open
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
Open
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
Conversation
Manohar Paturi (ManoharPaturi)
requested review from
SergeyMenshykh,
Tao Chen (TaoChenOSU),
Eduard van Valkenburg (eavanvalkenburg),
Giles Odigwe (giles17),
Jose Alvarez (jpalvarezl),
Evan Mattson (moonbox3),
Roger Barreto (rogerbarreto),
sophia-ramsey and
westey (westey-m)
as code owners
October 26, 2026 17:48
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
October 26, 2026 17:48 — with
GitHub Actions
Inactive
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
October 26, 2026 17:48 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
requested changes
Oct 27, 2026
Eduard van Valkenburg (eavanvalkenburg)
left a comment
Member
There was a problem hiding this comment.
Manohar Paturi (@ManoharPaturi) Four material issues remain in the memory topic storage changes:
- In
python/packages/core/agent_framework/_harness/_memory.py:811-825,glob(f"{prefix}*.md")accepts longer unrelated slugs and returns the first match. A missing topic can therefore read, merge into, or delete another topic; colliding names such asC++andC#can also merge. Please validate exact topic/slug identity rather than accepting arbitrary prefixes. - In
_memory.py:884-894, updating a legacy filename writes a new digest file without retiring the matching legacy file. Both remain visible, lookup can return stale content, and deletion can resurrect the legacy record. Please implement a one-authoritative-record migration/update lifecycle. - In
_memory.py:783-784, index links and provider selection still use the old nonunique slug instead of the actual persisted filename/exact topic identity. Collision-safe files can therefore produce broken links and duplicate the wrong topic during injection. Please use the persisted storage identity consistently. - In
_memory.py:886, writing fromrecord.topicignores the publicMemoryTopicRecord(slug=...)override. Please preserve explicit slug lookup compatibility while introducing collision-safe storage identities.
Please address all four before merge.
Distinct topics can share a readable slug, so a slug-only stem let the second topic silently overwrite the first. The stem now appends a digest of the normalized topic, and the storage layer keeps one authoritative record: lookups validate every candidate against the record it actually holds instead of accepting a filename prefix, so a missing topic can never read, merge into, or delete a longer slug; rewriting a topic that lived at a legacy slug-only file retires the legacy file; index pointer links and provider lookups use the persisted stem; and an explicit slug override is persisted in the record and stays findable by that slug, without letting lookups for other names bleed into the overridden record. Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
Manohar Paturi (ManoharPaturi)
force-pushed
the
fix/memory-topic-slug-collision
branch
from
October 27, 2026 11:53
ed16818 to
8d4eb10
Compare
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
October 27, 2026 11:53 — with
GitHub Actions
Inactive
Contributor
Author
|
All four addressed in 8d4eb01, verified end to end against the store before pushing.
The five new tests fail on the previous head. The memory suite passes at 40 tests, ruff check and format are clean. |
Manohar Paturi (ManoharPaturi)
requested a review
from Eduard van Valkenburg (eavanvalkenburg)
October 27, 2026 12:21
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
October 27, 2026 12:49 — with
GitHub Actions
Inactive
Contributor
Author
|
Eduard van Valkenburg (@eavanvalkenburg) the PR body now carries the required Contribution Checklist with the non-breaking item confirmed, matching the template. Everything from your review is addressed in the latest push and the thread replies have the verification details. |
This branch was previously deployed
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.
Motivation & Context
MemoryFileStorekeyed every topic file by_slugify_topic(topic), which is many to one:C ++andC #both slug toc.write_topicoverwrites the slug path unconditionally, so writing a second topic that shares a slug silently destroyed the first topic's memories. Reproduced on main: after writing both topics,get_topic("C ++")returned the C # memory and the C ++ memory was gone. The store's own path components for owner, session, source, and scope all use the injective_storage_key_segmentderivation for exactly this reason; the topic filename was the one mapping left below that standard.Description & Review Guide
record.slug). When a slug-only lookup is ambiguous because several topics share that slug, the file whose recorded topic matches the lookup wins, else the first stem in sorted order keeps the choice deterministic._existing_topic_path, and the regression test writingC ++thenC #and reading both back, which fails on main.Related Issue
Fixes #9723
AI Assistance
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.