mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1524] [Issue]: Long-Term Memory: extraction drops a memory that cites its source by the source note id #1504
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#1504
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/1524
Originally assigned to: @Promansis on GitHub.
Summary
The extraction request tells the model it may link to the source note by its id (
sourceNote.id), and asks every event to do so withextracted_from. When the model cites that id with any event relation instead, such as{"target":"source_chat_summary_…","relation":"evidenced_by"}, the server turns it into an event id that doesn't exist,timeline_source_chat_summary_…, and validation drops the whole unit as "linked to a memory this extraction could not find". Two steps do this. Raw parsing reads the bare id as an event name. And on a source whose text has section headings (## world_factand the like), the structured-summary normalizer adds thetimeline_prefix again after raw parsing. The written-out formsource_note:<id>gets past raw parsing, but on a source with headings the normalizer prefixes it too, so today it survives only on sources without headings.In live runs with the 1.4.55 prompt it never happened. With the shorter wording that the extraction request has sent since 1.4.65 (#1517), it cost one memory in 4 of 7 runs (measured on the version of that wording planned before #1517 merged).
Affected package
long-term-memory1.4.55 (upstream/staging8b72729f1); line references below are on8b72729f1. Still present on 1.4.66 (77acb942b). Since #1517 the request no longer carries the two schema descriptions quoted below, which is the shorter wording that produced the drops in the measurement.S=packages/long-term-memory/src/engine/packages/server/src/services/long-term-memoryExpected behavior
A link whose target is the source note's own id keeps that id, whatever the relation, whether it is written bare or as
source_note:<id>, and whether or not the source has section headings. Validation then judges the link as it does today.Actual behavior
S/extraction/evidence-unit-extraction.ts:87-88). The provider schema describes a link target as a note id "or the source note id" (:498), and the prompt's schema text says targets may be "copied exactly from sourceNote.id" (:1248). On 1.4.66 both schema descriptions are gone (#1517) and the two rules remain (:77-78).normalizeRawLinkTarget(:884-913) keeps a target unchanged only when it is writtensource_note:<id>(:889,:893), is a note id derived from a unit in the same answer (targetNoteIds,:896), or carries a note prefix (timeline_,thread_,world_,tone_,rel_,char_;:72,:901). Source note ids start withsource_(S/sources/source-identity.ts:13), so a bare one matches none of these. For an event relation (occurred_in,triggered_by,resolved_in,evidenced_by,caused_by,planted_in,paid_off_in;:75-83) it is then prefixed as an event (:903). Forblocksit becomes athread_id (:904).extracted_fromis not an event relation, so that one keeps the bare id, which is why most source links work.normalizeStructuredSummaryEvidenceUnits(S/extraction/structured-summary-normalizer.ts:201) passes every unit throughnormalizeUnit(:238-242), which normalizes each link withnormalizeLinkTarget(:527,:1574,:1647-1660). That keeps a target unchanged only when it carries a note prefix (NOTE_ID_PREFIX_PATTERN,:69, which has nosource_), and otherwise prefixes the target of an event relation withtimeline_(:1655; relations:86-94) and ofblockswiththread_(:1656). It runs on the units raw parsing returns, in source extraction (S/extraction/source-extraction.ts:554) and again incompileEvidenceUnitExtraction(S/extraction/evidence-unit-extraction.ts:1536). Raw parsing turnssource_note:<id>into the bare id (:893), so the normalizer re-prefixes that form too. Without headings (:226-235) it doesn't callnormalizeLinkTarget.linkTargetDiagnostics(S/extraction/evidence-unit-validation.ts:676-697) then drops the unit withunknown_link_targetanddetails.linkTarget: "timeline_source_…".Measurement
Live extraction runs on a private 15-source vault copy, with Claude Haiku 5.5 and Claude Sonnet 5.5 through
claude -p(Claude models only). Only aggregate counts are shared.All 9 dropped units were static: 7
world_fact, 1threadand 1anchor. Their links to the bare source id were 8evidenced_byand 1planted_in(the anchor). The drops came from 4 sources, all with section headings (13 of the 15 sources have them), so fixing raw parsing alone would not have kept any of them.Steps to reproduce
## world_fact. CallparseEvidenceUnitPayloadwith a staticworld_factunit whose only link is{ target: <source note id>, relation: "evidenced_by" }, passingsource_note:<source note id>as trusted evidence, as extraction does (:1445-1450).timeline_<source note id>. Written assource_note:<source note id>, the target parses to the bare id instead.compileEvidenceUnitExtraction. In both forms the fact is dropped withunknown_link_target. On a source without headings only the bare form is dropped.Minimal fix
One PR, patch bump. Two files, one guard each; both are needed.
S/extraction/evidence-unit-extraction.ts): innormalizeEvidenceUnitResponse(:674), after the target hints are built (:686), add the id of everysource_note:<id>in the trusted evidence totargetNoteIds. Extraction passes the source note's evidence as trusted evidence (evidenceFromSourceNote,:188-191), whose first entry issource_note:<source note id>, so the bare id then passes unchanged at:896, exactly as thesource_note:<id>form does.S/extraction/structured-summary-normalizer.ts): giveStructuredSummaryHints(:44-51) an optionalsourceNoteId, set it fromsourceNote?.idwhere the hints are built (:238), and innormalizeLinkTargetreturn an identifier equal to it unchanged, beside the note-prefix check (:1654).source_…id, or an event subject that happens to start withsource_, is prefixed as today.## Unreleased: "Extraction no longer drops a memory that cites the chat summary or import it came from, for example as its evidence."Not included
source_id. A source the extraction doesn't hold can't be a valid link target, and validation would drop it anyway.sourceNote.id; the server now agrees with it.Regression proof
In
tests/long-term-memory-extraction-graph.regression.ts, right after the "Source-prefixed link normalization" case (:1338-1357), which coverssource_note:<id>in raw parsing:## world_factsection. Parse two staticworld_factunits withsource_note:<source id>as trusted evidence. The first's only link isevidenced_byto the bare source id; the second's isevidenced_bytosource_chat_other_summary, a source this extraction doesn't hold.timeline_source_chat_other_summary, so only the exact id is kept.compilehelper (compileEvidenceUnitExtraction, which applies the structured normalizer). Expect one unit kept, with itsevidenced_bylink to the source note. It fails today (none kept), and it also fails with either guard alone.Environment
staging2039583ca)upstream/staging8b72729f1)Logs, screenshots, or video
None. The counts come from a private vault copy, so only aggregates are shared.
Additional context
Tracker item OT-7. Found while reviewing the structured-summary backfill fix (#1505, merged as #1511). Its first version kept a bare
source_id in the summary normalizer, which on its own keeps nothing: raw parsing has already turned a bare id intotimeline_source_…by then. The normalizer does receive the bare id when the model writessource_note:<id>(raw parsing unwraps it), and with this fix also when the model writes the bare id. On a source with section headings it then prefixes it again, so both places need the guard.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: