mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1505] [Issue]: Long-Term Memory: the structured-summary backfill drops character facts whose cause is written in words #1496
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#1496
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 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1505
Originally assigned to: @Promansis on GitHub.
Summary
When a chat summary uses the structured format, the server adds the character facts the model missed from the summary's
character_factsection (the backfill). If one of those lines has a cause or evidence field written in words, for examplecaused_by: the night lesson, the server turns the words into an event id (timeline_the_night_lesson) without checking that any event has that id. None does, so validation drops the fact the server has just added. The extraction then reports a partial success with "Dropped a candidate that linked to a memory this extraction could not find or did not keep", although the model never wrote that link.Relationship lines with the same field already go through a resolver. It matches the words to an event in the answer or the vault, and adds an event if none matches. Character lines skip that resolver.
In the live runs these are most of the "could not find" drops: up to 3 lost facts per run with today's code, on both models and in every prompt variant.
Affected package
Re-checked 2026-10-21 at
upstream/stagingedb9c4928(long-term-memory 1.4.57, built on the Engine's host, capability API 1.341): the fix applies unchanged there; line numbers are at the commit named below.long-term-memory1.4.54 (upstream/stagingb1873710f). The same at #1473 headc4b1c0192, which doesn't changestructured-summary-normalizer.tsorevidence-unit-validation.ts.S=packages/long-term-memory/src/engine/packages/server/src/services/long-term-memoryExpected behavior
S/extraction/evidence-unit-extraction.ts:87): it links only to an event in the same answer or a note the extraction already holds.:88).Actual behavior
parseStructuredCharacterLine(S/extraction/structured-summary-normalizer.ts:1183) reads a cause or evidence field at:1256-1264.timelineLinkFromValue(:1588) callstimelineTargetFromValue(:1593-1600), which turns any non-empty value intotimeline_<words>. Nothing checks that id against the answer's events, the summary's own event ids (hints.eventIds) or the existing notes.characterTimelineRelation(:1639-1645) keepscaused_byfordevelopmentsandprogressionand turns it intoevidenced_byfor every other section.maybeAddStructuredCharacterUnits(:1132) appends the unit when the model's answer doesn't already cover the fact.normalizeStructuredSummaryEvidenceUnitsdoesn't give itexistingNotes(:262-271).maybeAddStructuredRelationshipUnits(:642) callsresolveStructuredCauseTarget(:881-928). That tries an exact id (exactTargetFromCauseValue,:950), then a word match (fuzzyTimelineTargetFromCause,:961) over the answer's events and the existing notes (timelineTargetCandidates,:930), then adds an event (structuredCauseTimelineUnit,:991).linkTargetDiagnostics(S/extraction/evidence-unit-validation.ts:676-697) drops the added fact asunknown_link_targetatvalidationStage: "initial".S/extraction/source-extraction.ts:554-565) uses the defaultaddStructuredUnits = true(:210). See the PL-3 correction in the hygiene issue (RT-4, RT-8, RS-4, PL-3).Measurement
T6 harness on a private 15-source vault copy (private harness, real
prepareLongTermMemorySource, responses cached). Modelsclaude-haiku-5-5andclaude-sonnet-5-5throughclaude -p. These are Claude models only, not every provider people use. Only aggregate counts are shared.Drops for a link target the extraction "could not find", per run, split by where the link came from:
reduced, Haiku / Sonnetreduced2, Haiku a / b, Sonnetreduced3, Haiku (6 runs)reduced3, Sonnetcharacter_factlines give their cause in words. In the other, one line names an event id that no source in the vault has.reduced2/reduced3runs. The EX-I5 wording drops the long link descriptions, and models then sometimes cite the source note withevidenced_byinstead ofextracted_from.reduced2Haiku b come from events rejected for a missingsectionKey, and 3 inreduced3Haiku a are anchors like the two above.Steps to reproduce
## timeline_eventsection and a## character_factline such as- Mara | sectionKey: facts | Learned the observatory script. | caused_by: the night lesson.unknown_link_targetwithdetails.linkTarget: "timeline_the_night_lesson"on a unit the server added.Minimal fix
One PR, patch bump. Only
S/extraction/structured-summary-normalizer.ts.maybeAddStructuredCharacterUnits(:1132): pass inexistingNotesfrom:262. For each cause or evidence value on a character line, resolve it the way relationships do:exactTargetFromCauseValue, thenfuzzyTimelineTargetFromCause, overtimelineTargetCandidates(next, existingNotes). Hand that resolver toparseStructuredCharacterLineinoptionsand call it in place oftimelineLinkFromValueat:1258.developmentsorprogressionline, use the existing fallback (deriveTimelineLinkForStructuredCharacter,:1602: an event id named in the line, or the only event), but keep its link only when the extraction holds that event. On any other line leave the link out. (The fallback can pick an event the summary declares in## timeline_eventeven when the model left that event out, which would drop the fact again asunknown_link_target. Values that are empty, such ascaused_by: none, keep today's fallback.)closeSourceEventGraph(S/extraction/evidence-unit-extraction.ts:1742) assource_event_graph_open, which names the real problem.## Unreleased: "Memories added from a structured chat summary are no longer dropped when their 'because of' note doesn't match an event."Not included
Model links to the source note by its bare id (the "Source note link" column above: none today, a few with the EX-I5 wording). Raw parsing turns them into
timeline_source_…before the normalizer runs (normalizeRawLinkTarget,S/extraction/evidence-unit-extraction.ts:884: onlysource_note:<id>or an id from the answer passes unchanged), so a fix in the normalizer never sees them. (Tracked as OT-7, the bare source note link issue, to file before or with the extraction-envelope issue (EX-I5), whose wording makes these links more likely.)Tightening the word matcher. It accepts a cause that contains an event's subject id as a substring, with no word boundary, and the same matcher serves relationship causes. Suggest a separate issue for both paths.
Adding the events a summary declares but the model left out. When the model skips such an event, its own anchors that point at it are dropped. That is the case decision D on EX-I11 covers with the EX-I5 prompt rule, not a server link loss.
Looking up link targets in the whole vault (EX-I11 option B, rejected).
Regression proof
Write first; it must fail on the current code.
In
tests/long-term-memory-extraction-graph.regression.ts, next to the structured character cases (:586-616,:648). Use the file'scompilehelper (:102) withskipStructuredBackfill = falseso the backfill runs through validation. Validation drops appear incompile().diagnosticsascandidate_dropped_*with the validator code indetails.validatorCode, so check both. Keep the fact text static:Learned the …matchesCHARACTER_DEVELOPMENT_PATTERNand becomes adevelopmentsfact.factsline withcaused_by: the night lesson, no matching event andunits: []. Expect the added fact to be kept with notimeline_the_night_lessonlink, and nounknown_link_target. It fails today.night_lessonin the answer. Expect the link to resolve to that event's note id after the source suffix. It fails today, because the words don't equal the id.developmentsline whose cause matches nothing. Expect notimeline_<words>link. If the unit is dropped, the code issource_event_graph_open.caused_by: night_lessonand an eventnight_lessonkeeps today's link. It passes today.existingNotes). Expect the link to that note. It fails today.evidenced_by: <source note id>. Expect the link to the source note. It fails today.market_firein## timeline_event, an answer without that event, and adevelopmentsline whose cause matches nothing. Expectsource_event_graph_openand nounknown_link_target.Environment
staging2039583ca)upstream/stagingb1873710f)Logs, screenshots, or video
None. The counts come from a private vault copy, so only aggregates are shared.
Additional context
Tracker item EX-I11a (split from EX-I11; found by the T6 live extraction runs). Related: the bare source note link issue (OT-7) and the extraction-envelope issue (EX-I5).
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: