[GH-ISSUE #1550] [Issue]: Long-Term Memory: a structured summary reads a name starting with Char or Rel as an id, so its section hint and lines are lost #1518

Closed
opened 2026-10-22 04:02:54 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Promansis on GitHub (Oct 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1550

Originally assigned to: @Promansis on GitHub.

Summary

When a structured chat summary writes a character's name out (- Char Aznable | …, character: Char Aznable, - Char Aznable: …, or a leading pair such as - Rel Varga, Sayla Mass | …), the summary parser reads the name as if it were a memory id: it removes a leading char_ or rel_ once. A name that starts with that word loses it. "Char Aznable" becomes aznable, and the pair "Rel Varga, Sayla Mass" becomes varga_sayla_mass. Neither matches anyone in the chat, so:

  • A summary line about Char Aznable is dropped as "not in the trusted chat roster or bound memories". When the model returned the same fact, only the summary's copy is lost (it shows as a rejected candidate in Review); a fact only the summary has is lost outright. The same line for "Mara" is saved.
  • A relationship that only the summary mentions, for a pair whose first name starts with "Rel", is dropped the same way, and no relationship memory is made.
  • The section a summary gives the character (character: Char Aznable with section: profile) is stored under aznable. Today it matches only because Char Aznable's facts go to a wrong, shortened memory char_aznable. Once the facts go to the character's own memory char_char_aznable (the prefix-word memory id fix, #1543, PR #1548), the hint misses and the fact takes its section from its wording instead, for example Items for "carries a red pendant".

A line that writes the id made from the name instead (subject: char_aznable, the form the Engine's built-in LTM summary prompt asks for) loses the word the same way. That case is not fixed here (see Not included).

Affected package

long-term-memory 1.4.76 (upstream/staging 79d45f80e) with the #1543 fix (PR #1548, 1.4.77).

S = packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory

Expected behavior

A character or relationship whose name a structured summary writes out is read by its whole name, the way identity reads it. The summary's section hint reaches the character's memory, and its lines are saved to the memory identity chose, whatever the name's first word.

Actual behavior

Line numbers are on that tree (refreshed 2026-10-21; first checked on 6a2dfb7c6), all in S/extraction/structured-summary-normalizer.ts.

  • characterSubject (:1542-1545) reads a section's character: value as an id and removes char_ once, so "Char Aznable" is keyed aznable (structuredSummaryHints, :503).
  • characterSectionKey (:1593-1597) looks the hint up by the fact's subject id. When it misses, structuredCharacterSectionKey (:1599-1604) moves a facts, core or profile fact to items or developments by its wording.
  • parseStructuredCharacterLine (:1204) does the same to a summary line, whether the name leads the line (- Char Aznable | …, :1240), sits in a field (character: Char Aznable, :1256) or is the key (- Char Aznable: …, :1297). The subject is stripped at :1315 to aznable. The line carries no names, so identity cannot match aznable to Char Aznable and drops it with untrusted_subject_identity.
  • parseStructuredRelationshipLine (:743) strips a leading pair (:773) or an id field (:785), and strips again at :851: "Rel Varga, Sayla Mass" is varga_sayla_mass, dropped the same way. A pair given in a characters: field keeps its names and is not affected.
  • Ordinary names are not affected: "Mara" is mara, which identity matches to Mara.

Steps to reproduce

  1. Put characters named "Char Aznable", "Mara", "Rel Varga" and "Sayla Mass" in the chat.

  2. Extract from a chat summary in the structured format, with the model returning the pendant fact for Char Aznable:

    ## character_fact
    character: Char Aznable
    section: profile
    - Char Aznable | section: profile | text: Char Aznable carries a red pendant.
    - Char Aznable | section: profile | text: Char Aznable leads the Red Comet squadron.
    ## relationship_state
    - Rel Varga, Sayla Mass | text: Rel Varga owes Sayla Mass a favor.
    
  3. Both Char Aznable lines are dropped as untrusted_subject_identity with subject aznable, so "leads the Red Comet squadron" is lost; the relationship line is dropped with subject varga_sayla_mass, and no relationship memory is created. With "Mara" in place of "Char Aznable" both lines are saved.

  4. With the prefix-word memory id fix (#1543, PR #1548) in place, the pendant fact is saved to char_char_aznable under Items instead of Profile.

Minimal fix

One PR, patch bump. One source file, no new file.

  • Read a value with a space in it as a name, unless its first word has an underscore; read anything else as an id. An id has no space, and an id followed by a name (char_mara (Mara), char_mara - Mara) has an underscore in its first word. A name gets the subject id identity gives its memory: the prefix plus the name, then the prefix removed with the prefix-word helper from the #1543 fix (unprefixedSubjectId), so "Char Aznable" is char_char_aznable and "Mara Lee" is mara_lee. An id is stripped once, as today.
  • Use it for the character section hint, for the subject of a character line (leading name, character: field, or name as key), and for a relationship line's leading pair or id field. The relationship line's second strip goes; a pair from a characters: field is stripped once, as before.
  • Keep the old key for the section hint too, so a memory saved earlier under the shorter id (char_aznable) still takes it.
  • The event the parser writes for a relationship line's cause takes its text from the pair's id. It now drops the prefix once, so "Rel Varga, Sayla Mass" reads "rel and varga and sayla and mass relationship changed after …" rather than "rel and rel and …".
  • CHANGELOG under ## Unreleased: "Extraction from a structured chat summary now reads a character name that starts with "Char", such as "Char Aznable", or a relationship pair whose first name starts with "Rel", as a name instead of an id when the summary writes the name out. … A line that writes an id made from the name instead, such as subject: char_aznable, is still read as an id."

Not included

  • A line that writes an id made from the name, which is what the Engine's built-in LTM summary prompt asks for (subject: char_aznable for Char Aznable), is still read as an id and dropped as aznable. The parser can't tell it apart from a memory id such as Mara's char_mara without the chat's character list, which it does not get; passing that list in touches source-extraction.ts and is a separate follow-up.
  • An id written with a space in lower case (- char mara | …) now reads as a name and is dropped (it was saved to Mara before). The Engine prompt asks for snake_case ids, so this form is unlikely.
  • A section hint for "Char Aznable" is still also stored under aznable, so in a chat that also has a character called "Aznable" it reaches Aznable's memory too, as today.
  • A leading pair with the "Char …" name first (- Char Aznable, Mara | …) is still dropped, as today; the same pair in a characters: field, or the other way round, is kept.
  • A summary that writes the memory's full id (char_char_aznable, rel_rel_varga_sayla_mass) without a space is still stripped once (char_aznable), as today: the section hint misses, and a relationship line is dropped. Changing how written ids fold would also change char_char_mara, which today means Mara.
  • A capitalised id without a space (Char_Aznable) is still read as an id.
  • A pair joined with "and" in the leading text (- Rel Varga and Sayla Mass | …, also - Ana and Bo | …) gives a subject that contains and, which identity can't match, before and after.
  • The cause event's text is still built from the id ("varga and sayla and mass" today), not from the names.
  • A name in a line's character: field is still not attached to the line as a name, as today.

Regression proof

In tests/long-term-memory-extraction-graph.regression.ts, at the end of the prefix-word memory id case (added by #1543, PR #1548): run processLongTermMemorySource with the same roster (Char Aznable, Rel Varga, Sayla Mass, Mara) on a structured summary with a character: Char Aznable / section: profile section, a character: Mara / section: profile section (including two lines written as char_mara (Mara)), and relationship lines for "Rel Varga, Sayla Mass" (leading pair, relationship: field, a new fact with a cause). The model returns the Char Aznable and Mara facts but no relationship.

  • The created memories are char_char_aznable, char_mara and rel_rel_varga_sayla_mass; both character memories hold only profile; the field-form line "leads the Red Comet squadron" reaches char_char_aznable; the two char_mara (Mara) lines reach char_mara; nothing is dropped; the cause event reads "rel and varga and sayla and mass relationship changed after the hangar fire."
  • A fact for a memory saved under the shorter id (aznable) still takes the summary's profile.

Without the fix it fails at the first check (no relationship memory), and putting back any one changed line fails one of the checks.

Environment

  • Marinara Engine version: 2.5.1 (staging 87d1ccadc)
  • Package version: long-term-memory 1.4.77 (upstream/staging 79d45f80e with the #1543 fix, PR #1548)
  • Install type: source (code reading and a fixture-model run through processLongTermMemorySource)
  • OS + version: not platform-specific
  • Browser or app shell: any

Logs, screenshots, or video

None. The reproduction uses fixture names, not user data.

Additional context

Tracker item OT-14. Found while preparing and reviewing the prefix-word memory id fix (#1543, PR #1548), which must land first: this fix uses its helper and adds to its test case.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1550 Originally assigned to: @Promansis on GitHub. ## Summary When a structured chat summary writes a character's name out (`- Char Aznable | …`, `character: Char Aznable`, `- Char Aznable: …`, or a leading pair such as `- Rel Varga, Sayla Mass | …`), the summary parser reads the name as if it were a memory id: it removes a leading `char_` or `rel_` once. A name that starts with that word loses it. "Char Aznable" becomes `aznable`, and the pair "Rel Varga, Sayla Mass" becomes `varga_sayla_mass`. Neither matches anyone in the chat, so: - A summary line about Char Aznable is dropped as "not in the trusted chat roster or bound memories". When the model returned the same fact, only the summary's copy is lost (it shows as a rejected candidate in Review); a fact only the summary has is lost outright. The same line for "Mara" is saved. - A relationship that only the summary mentions, for a pair whose first name starts with "Rel", is dropped the same way, and no relationship memory is made. - The section a summary gives the character (`character: Char Aznable` with `section: profile`) is stored under `aznable`. Today it matches only because Char Aznable's facts go to a wrong, shortened memory `char_aznable`. Once the facts go to the character's own memory `char_char_aznable` (the prefix-word memory id fix, #1543, PR #1548), the hint misses and the fact takes its section from its wording instead, for example Items for "carries a red pendant". A line that writes the id made from the name instead (`subject: char_aznable`, the form the Engine's built-in LTM summary prompt asks for) loses the word the same way. That case is not fixed here (see Not included). ## Affected package `long-term-memory` 1.4.76 (`upstream/staging` 79d45f80e) with the #1543 fix (PR #1548, 1.4.77). `S` = `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory` ## Expected behavior A character or relationship whose name a structured summary writes out is read by its whole name, the way identity reads it. The summary's section hint reaches the character's memory, and its lines are saved to the memory identity chose, whatever the name's first word. ## Actual behavior Line numbers are on that tree (refreshed 2026-10-21; first checked on 6a2dfb7c6), all in `S/extraction/structured-summary-normalizer.ts`. - `characterSubject` (`:1542-1545`) reads a section's `character:` value as an id and removes `char_` once, so "Char Aznable" is keyed `aznable` (`structuredSummaryHints`, `:503`). - `characterSectionKey` (`:1593-1597`) looks the hint up by the fact's subject id. When it misses, `structuredCharacterSectionKey` (`:1599-1604`) moves a `facts`, `core` or `profile` fact to `items` or `developments` by its wording. - `parseStructuredCharacterLine` (`:1204`) does the same to a summary line, whether the name leads the line (`- Char Aznable | …`, `:1240`), sits in a field (`character: Char Aznable`, `:1256`) or is the key (`- Char Aznable: …`, `:1297`). The subject is stripped at `:1315` to `aznable`. The line carries no names, so identity cannot match `aznable` to Char Aznable and drops it with `untrusted_subject_identity`. - `parseStructuredRelationshipLine` (`:743`) strips a leading pair (`:773`) or an id field (`:785`), and strips again at `:851`: "Rel Varga, Sayla Mass" is `varga_sayla_mass`, dropped the same way. A pair given in a `characters:` field keeps its names and is not affected. - Ordinary names are not affected: "Mara" is `mara`, which identity matches to Mara. ## Steps to reproduce 1. Put characters named "Char Aznable", "Mara", "Rel Varga" and "Sayla Mass" in the chat. 2. Extract from a chat summary in the structured format, with the model returning the pendant fact for Char Aznable: ```text ## character_fact character: Char Aznable section: profile - Char Aznable | section: profile | text: Char Aznable carries a red pendant. - Char Aznable | section: profile | text: Char Aznable leads the Red Comet squadron. ## relationship_state - Rel Varga, Sayla Mass | text: Rel Varga owes Sayla Mass a favor. ``` 3. Both Char Aznable lines are dropped as `untrusted_subject_identity` with subject `aznable`, so "leads the Red Comet squadron" is lost; the relationship line is dropped with subject `varga_sayla_mass`, and no relationship memory is created. With "Mara" in place of "Char Aznable" both lines are saved. 4. With the prefix-word memory id fix (#1543, PR #1548) in place, the pendant fact is saved to `char_char_aznable` under Items instead of Profile. ## Minimal fix One PR, patch bump. One source file, no new file. - Read a value with a space in it as a name, unless its first word has an underscore; read anything else as an id. An id has no space, and an id followed by a name (`char_mara (Mara)`, `char_mara - Mara`) has an underscore in its first word. A name gets the subject id identity gives its memory: the prefix plus the name, then the prefix removed with the prefix-word helper from the #1543 fix (`unprefixedSubjectId`), so "Char Aznable" is `char_char_aznable` and "Mara Lee" is `mara_lee`. An id is stripped once, as today. - Use it for the character section hint, for the subject of a character line (leading name, `character:` field, or name as key), and for a relationship line's leading pair or id field. The relationship line's second strip goes; a pair from a `characters:` field is stripped once, as before. - Keep the old key for the section hint too, so a memory saved earlier under the shorter id (`char_aznable`) still takes it. - The event the parser writes for a relationship line's cause takes its text from the pair's id. It now drops the prefix once, so "Rel Varga, Sayla Mass" reads "rel and varga and sayla and mass relationship changed after …" rather than "rel and rel and …". - **CHANGELOG under `## Unreleased`**: "Extraction from a structured chat summary now reads a character name that starts with "Char", such as "Char Aznable", or a relationship pair whose first name starts with "Rel", as a name instead of an id when the summary writes the name out. … A line that writes an id made from the name instead, such as `subject: char_aznable`, is still read as an id." **Not included** - A line that writes an id made from the name, which is what the Engine's built-in LTM summary prompt asks for (`subject: char_aznable` for Char Aznable), is still read as an id and dropped as `aznable`. The parser can't tell it apart from a memory id such as Mara's `char_mara` without the chat's character list, which it does not get; passing that list in touches `source-extraction.ts` and is a separate follow-up. - An id written with a space in lower case (`- char mara | …`) now reads as a name and is dropped (it was saved to Mara before). The Engine prompt asks for snake_case ids, so this form is unlikely. - A section hint for "Char Aznable" is still also stored under `aznable`, so in a chat that also has a character called "Aznable" it reaches Aznable's memory too, as today. - A leading pair with the "Char …" name first (`- Char Aznable, Mara | …`) is still dropped, as today; the same pair in a `characters:` field, or the other way round, is kept. - A summary that writes the memory's full id (`char_char_aznable`, `rel_rel_varga_sayla_mass`) without a space is still stripped once (`char_aznable`), as today: the section hint misses, and a relationship line is dropped. Changing how written ids fold would also change `char_char_mara`, which today means Mara. - A capitalised id without a space (`Char_Aznable`) is still read as an id. - A pair joined with "and" in the leading text (`- Rel Varga and Sayla Mass | …`, also `- Ana and Bo | …`) gives a subject that contains `and`, which identity can't match, before and after. - The cause event's text is still built from the id ("varga and sayla and mass" today), not from the names. - A name in a line's `character:` field is still not attached to the line as a name, as today. ## Regression proof In `tests/long-term-memory-extraction-graph.regression.ts`, at the end of the prefix-word memory id case (added by #1543, PR #1548): run `processLongTermMemorySource` with the same roster (Char Aznable, Rel Varga, Sayla Mass, Mara) on a structured summary with a `character: Char Aznable` / `section: profile` section, a `character: Mara` / `section: profile` section (including two lines written as `char_mara (Mara)`), and relationship lines for "Rel Varga, Sayla Mass" (leading pair, `relationship:` field, a new fact with a cause). The model returns the Char Aznable and Mara facts but no relationship. - The created memories are `char_char_aznable`, `char_mara` and `rel_rel_varga_sayla_mass`; both character memories hold only `profile`; the field-form line "leads the Red Comet squadron" reaches `char_char_aznable`; the two `char_mara (Mara)` lines reach `char_mara`; nothing is dropped; the cause event reads "rel and varga and sayla and mass relationship changed after the hangar fire." - A fact for a memory saved under the shorter id (`aznable`) still takes the summary's `profile`. Without the fix it fails at the first check (no relationship memory), and putting back any one changed line fails one of the checks. ## Environment - Marinara Engine version: 2.5.1 (`staging` 87d1ccadc) - Package version: long-term-memory 1.4.77 (`upstream/staging` 79d45f80e with the #1543 fix, PR #1548) - Install type: source (code reading and a fixture-model run through `processLongTermMemorySource`) - OS + version: not platform-specific - Browser or app shell: any ## Logs, screenshots, or video None. The reproduction uses fixture names, not user data. ## Additional context Tracker item OT-14. Found while preparing and reviewing the prefix-word memory id fix (#1543, PR #1548), which must land first: this fix uses its helper and adds to its test case. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
Author
Owner

@Promansis commented on GitHub (Oct 21, 2026):

Fixed in staging by #1552 (long-term-memory 1.4.79).

<!-- gh-comment-id:6322787638 --> @Promansis commented on GitHub (Oct 21, 2026): Fixed in staging by #1552 (long-term-memory 1.4.79).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#1518
No description provided.