mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1515] [Issue]: Long-Term Memory: a relationship or character change links to an unrelated event whose id appears inside a word of its cause or text #1502
Labels
No labels
agent: chess
agent: conversation-calls
agent: eightball
agent: haptic
agent: hierarchical-maps
agent: hierarchical-maps
agent: illustrator
agent: poker
agent: rock-paper-scissors
agent: tic-tac-toe
agent: uno
artifacts
bug
bugfix
build
catalog
ci
client
dependencies
docs
documentation
enhancement
feature
fixed-in-staging
in-pr
normal-scope
packages
pull-request
qol
regression
roadmap
scope-risk
server
soup
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Agents#1502
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Promansis on GitHub (Oct 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1515
Originally assigned to: @Promansis on GitHub.
Summary
When a structured chat summary gives a relationship change's cause in words (
caused_by: the training), extraction looks for a matching event among the events in the answer and the existing timeline notes recalled for the source. That match compares ids as plain substrings. An event whose id is a short word such asrain,ashorballmatches any cause that contains those letters ("the training", "after the crash", "the football match"), and the relationship links to the wrong event. The reverse also happens: a short cause such asrain,fireortimematches inside a longer id (training_session,fireworks_show, or thetimeline_prefix that every event id carries).Events extracted from a chat summary are stored with a per-source hash at the end of their id (
timeline_rain_8d767c3b79). Such an id never fits inside a word of the cause, so for those stored events only the reverse direction goes wrong (a short cause such asrain,fire,timeorlineinside the longer id). The short-id-inside-a-word case, and the tie below, hit the events in the same answer (matched before the hash is added) and stored events without the hash, such as events from a lorebook source.A wrong match can also cost a right one. When a cause names an event in words and a shorter event id also appears inside one of the cause's words, both score as full matches, the tie rule discards both, and the relationship gets a new invented event instead of the one it named.
With the structured-summary backfill fix, character lines resolve their causes through the same matcher, so they are affected in the same way.
A second check has the same flaw. When a character line gives no cause (
caused_by: none), extraction looks for one of the event ids the summary declares inside the whole line, again as a plain substring, and links the fact to it when exactly one is found.art_showis found inside "will start showing", so a change about Mara starting to show her students a script links to an art show. With the structured-summary backfill fix, the same check also runs for a change fact whose written cause matches no event.Affected package
long-term-memory1.4.55 (upstream/staging8b72729f1).S=packages/long-term-memory/src/engine/packages/server/src/services/long-term-memoryExpected behavior
An event id matches a cause only on whole words, and the id's last word may be plural. "the training session" and "the training sessions" still link to
timeline_training_session, and "the rain" still links totimeline_rain, but "the training" does not link totimeline_rain, "rain" does not link totimeline_training_session, and a bare causetimeortimelinedoes not link to whatever event happens to be in the list. A character line names a declared event only when the event's id appears in it as whole words.A relationship change linked to an event from another source is still dropped afterwards, because a change must link to an event from the same source. That rule is not part of this issue.
Actual behavior
resolveStructuredCauseTarget(S/extraction/structured-summary-normalizer.ts:881) builds the candidates from the answer's events and the existing timeline notes (timelineTargetCandidates,:930-948; the notes come fromgetExistingTypedNotes,S/extraction/source-extraction.ts:484). It tries an exact id (exactTargetFromCauseValue,:950), thenfuzzyTimelineTargetFromCause(:961-989), and when nothing matches it creates a new event for the relationship (:913-927).fuzzyTimelineTargetFromCausescores a candidate as a full match (:968-972) when the cause's identifier is a substring of<subject id>_<target id>(for examplerain_timeline_rain), or when the candidate's subject id is a substring of the cause's identifier. Neither check looks at word boundaries, and the target id adds the wordtimelineto every candidate.:987) returns no match.exactTimelineTargetFromLine(:1621-1633) is the fallback for a character line without a cause (:1295-1303). It tests each declared event id, andtimeline_<id>, as a substring of the whole normalized line.Probe on the patch base, one existing timeline note per row unless stated (relationship line and character line give the same result). The last column says whether the same wrong result happens when the stored event's id carries the per-source hash:
timeline_raintimeline_raintimeline_ashtimeline_ashtimeline_balltimeline_balltimeline_training_sessiontimeline_training_sessiontimeline_fireworks_showtimeline_fireworks_showtimeline_rainortimeline_harbor_firetimeline_rainandtimeline_training_sessiontimeline_training_session"No match" means the relationship gets its own new event, as it does today for a cause that matches nothing, and the character fact keeps no link.
Line fallback, with the declared events
art_show("Mara exhibited her paintings at the harbor hall.") andmarket_fire("The market burned down.") both in the answer:- Mara | section: developments | text: Mara will start showing her students the old script. | caused_by: noneHow often this happens in real vaults was not measured. It needs an answered or stored event with a short id that occurs inside a word of the cause or line, or a short cause word inside an event id.
Steps to reproduce
Call
normalizeStructuredSummaryEvidenceUnitsin roleplay mode with this source text and an existing timeline notetimeline_rain("It rained over the harbor all night."; an id without the per-source hash, as a lorebook event has) inexistingNotes:The relationship unit's
caused_bylink targetstimeline_rain.Add a second existing note
timeline_training_sessionand change the cause to "the long training session at the old barracks". The relationship now links to a new event (timeline_alice_rowan_long_training_session_old_barracks_…) instead oftimeline_training_session.Line fallback: call it with this source text and the two events as answered
timeline_eventunits:The character fact links
caused_byto the art show event, andcompileEvidenceUnitExtractionkeeps that link.Minimal fix
One PR, patch bump. Only
S/extraction/structured-summary-normalizer.ts.fuzzyTimelineTargetFromCause: compare the cause and the candidate's subject id as whole_-separated words (both wrapped in_…_), with the same two containment checks. The id inside the cause also matches withsoresafter its last word, so a plural cause still finds its event, as the substring check allowed.<subject id> <target id>. The target is the subject id withtimeline_in front, so it added nothing but that prefix.exactTimelineTargetFromLine: look for each declared id in the line's words the same way, through one small helper shared with the cause check.timeline_<id>needs no separate test, since it holds the id as whole words.## Unreleased: "A relationship or character change from a chat summary no longer links to the wrong event because a short event name happens to sit inside a word."Not included
exactTargetFromCauseValue: it compares whole ids already.closeSourceEventGraph,S/extraction/evidence-unit-extraction.ts:1742-1790). That already happens today for a correct match and needs its own issue.weddingandwedding_night_attack), as today.Regression proof
In
tests/long-term-memory-extraction-graph.regression.ts, after the structured-summary backfill's cause cases:caused_by, normalized with existing timeline notes.timeline_rain, "rain" withtimeline_training_session, "fire" withtimeline_fireworks_show. Fails today on the first cause.timeline_rainandtimeline_training_sessionlinks both lines totimeline_training_session. Fails today (tie, so a new event and no link). The cause has too many other words for the word-overlap score, so only the id check can find this match; a fix that compares whole ids only fails it.timeline_training_sessionlinks both lines to it. Passes today; a whole-word fix without the plural fails it.art_showandmarket_firedeclared and answered, gets no link. Fails on top of the structured-summary backfill fix (it links to the art show event).Environment
staging2039583ca)upstream/staging8b72729f1)Logs, screenshots, or video
None. The tables above come from calling the normalizer directly with made-up notes; the line fallback case also through
compileEvidenceUnitExtraction.Additional context
Tracker item OT-5. Found while fixing the structured-summary backfill (EX-I11a), which must land first. The line fallback case was found in review of the prepared fix.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: