mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1448] [Issue]: Long-Term Memory: provider subject keys misattribute facts, late unit drops leave dangling links, blank templates use the Roleplay prompt #734
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#734
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 18, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1448
Originally assigned to: @Promansis on GitHub.
Summary
Three extraction defects in
evidence-unit-extraction.ts, filed together because they change the same file (tracker items EX-I2, EX-I1 and EX-I9):subjectKeysvalue silently binds a fact to the wrong character. The prompt hands the model every catalog key, tells it never to use them, and the server honours the field anyway. The resulting misattribution is only a warning, so it can auto-apply.Affected package
long-term-memory1.4.48 (upstream/staging1f7954305).S=packages/long-term-memory/src/engine/packages/server/src/services/long-term-memorySH=packages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memoryExpected behavior
subjectNames, asubjectKeysvalue in the provider response is ignored, and the prompt catalog carries only names and aliases.create_notelink target andadd_linktarget is an existing note, the source note, or a note the same draft creates. A unit whose only grounding link pointed at a dropped unit is dropped too and counted as a validation rejection; a non-structural dangling link is stripped with a diagnostic.Actual behavior
subjectNames: ["Alice"],subjectKeys: [<Bob's key>], text "Alice prefers tea over coffee" resolves to Bob with only asubject_identity_normalizedwarning. (Extraction stages audit, probe F.)threadwithclaimKind: "change"and no event link is dropped bycloseSourceEventGraph: theworld_factthat linkedinvolves -> thread_coffee_storycompiles ascreate_notewith that link intact,requiresReview: false. Preflight then throwsLong-term memory draft link target not found: thread_coffee_storyand the source is reportedfailedatfinalizewith the fingerprint already persisted, so a retry reproduces it. (Probe B.)DEFAULT_LTM_EXTRACTION_PROMPT(the Roleplay text).All locations below were checked at
1f7954305.Steps to reproduce
runLongTermMemoryEvidenceUnitExtractionwith a trusted catalog of Alice Vance and Bob Reyes and a provider response whose onecharacter_factunit names Alice and carries Bob's key. The mutation targetschar_bob_reyes.threadunit withclaimKind: "change"and no event link, plus aworld_factlinkinginvolvesto it) withapplyLowRisk. The draft commit throws at preflight.Minimal fix
One PR, patch bump.
1. Ignore provider keys (
S/evidence-unit-extraction.ts,S/subject-identity.ts)normalizedEvidenceUnitRecord(:609-616) only drops an emptysubjectKeysarray. WhenresolveSubjectNamesis on, drop the field altogether; pass the flag in from the parser. The internal resolver still setssubjectKeysitself for established and borrowed keys (S/subject-identity.ts:1279-1291), so that path is unchanged.evidenceUnitResponseFormat(:422, field at:506-510): omitsubjectKeysfrom the provider JSON schema whenresolveSubjectNamesis on.trustedLtmSubjectPromptCatalog(S/subject-identity.ts:703-714): stop serializingkeyandref; the model is asked to copy names and aliases only. Check that nothing but the prompt reads this output.:1263can keep its target-id half; the "database subject keys" half becomes moot.2. Re-close links after late drops (
S/evidence-unit-extraction.ts, compile section)validateLtmEvidenceUnits(S/evidence-unit-validation.ts:392-442). Three later passes drop units without re-closing:deduplicateUnits(:1533),dropLocalCharactersOutsideRoleplay(:1534-1538,:1672) andcloseSourceEventGraph(:1539,:1702). The compiler copies unit links verbatim.closeSourceEventGraph(and again forduplicateAliasClosure.units,:1560), run the validator's link-closure step over the surviving units, with the valid-target set rebuilt from the survivors plusexistingNotesand the source note, to a fixpoint withcloseSourceEventGraph. Export that step from the validator rather than copying it. Strip a non-structural dangling link and emit a diagnostic; drop the unit when the dangling link was the one that satisfied relationship support or event grounding, with validator codeunknown_link_target. Add the drops toallDroppedCandidatesanddroppedCandidateCount(:1567-1581) so the accounting still balances.changeunit without an event link (probe B); a timeline event withaffects_characterto a character unit whoseclaimKindischangeand that has no link back; any link to a local-character unit dropped outside Roleplay.3. Blank template falls back by mode (
S/extraction-config.ts,S/evidence-unit-extraction.ts)getLtmExtractionConfig(S/extraction-config.ts:50-58) returnstemplate.promptuntrimmed; treat a template whose trimmed prompt is empty as absent, so the existing fallback at:59-62picks the mode default.evidenceUnitMessages(:1160-1161) falls back toDEFAULT_LTM_EXTRACTION_PROMPT; useDEFAULT_LTM_EXTRACTION_PROMPTS_BY_MODE[options.mode ?? options.modes[0] ?? "roleplay"], the same expression:1530uses forallowedBuckets.SH/schema.ts:177(prompt: z.string().min(1)) with.trim(): stored settings that already hold a blank template would then fail to parse on load.CHANGELOG under
## Unreleased: one bullet each for 1, 2 and 3, written for users (which character a fact is saved to; imports no longer fail or block review on a dropped link; blank templates).Not included
unknown_link_target; the message fix is tracker EX-I6, in a separate issue.Regression proof
tests/long-term-memory-local-characters.regression.ts(already exercisessubjectKeys,:207-333,:716-722): the probe-F pair resolves to Alice with and without the wrong key; the serializedtrustedSubjectscarries nokeyorref; the established-key and borrowed-key cases still pass. Cases that model provider output and expect a provider key to win change to expect name resolution.tests/long-term-memory-extraction-graph.regression.ts: the probe-B fixture plus theaffects_characterand local-character variants. Assert that no compiledcreate_noteoradd_linktargets a dropped unit, the drop is counted, andpreflighton the resulting draft succeeds. Existing cases coverunknown_link_targetinside the validator (:204-231,:396-403) andsource_event_graph_openalone, never the combination.extraction-graph(which already importsevidenceUnitMessages), Conversation mode with a whitespacesystemPromptyields the Conversation default; andgetLtmExtractionConfigwith a blank active template forconversationreturnsDEFAULT_LTM_EXTRACTION_PROMPT_CONVERSATIONwithactivePromptTemplateId: null.extraction-reliability,candidate-reconciliation,routes-draftsandruntime.Environment
staging2039583ca)upstream/staging1f7954305)Logs, screenshots, or video
None. Found by the extraction stages audit (probes B and F, E1 reproductions) and confirmed by reading the code at
1f7954305.Additional context
Tracker items EX-I1, EX-I2 and EX-I9. Shares no source file with the other batch-1 issues except the
local-characterstest, which only this issue edits. The follow-up EX-I5 (prompt envelope) should wait for this PR.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: