mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1522] [Issue]: Long-Term Memory: after a rollback, a settings file written by the newer version can stop the package from starting #1505
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#1505
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/1522
Originally assigned to: @Promansis on GitHub.
Summary
After rolling back to an older Long-Term Memory version, any settings file written by the newer version can stop the package from starting. Since 1.4.39 (#1415) the loader tolerates unknown top-level keys. It still rejects:
activePromptTemplateIdsByMode;reasoningEffortlevel or a new mode insourcesAvailabilityModes;One such value fails activation, Settings, extraction, export and saving. The fix belongs in the one shared loader. It drops what this version doesn't know or can't accept, so that setting uses its default. It logs the field names and keeps the newer values on disk.
Affected package
long-term-memory1.4.55 (upstream/staging8b72729f1). Measured on 1.4.54 (b1873710f); #1473 (1.4.55) changed none of the lines below. Still present on 1.4.66 (77acb942b); the only shift is inSH/schema.ts, where lines after:1324sit two lines lower.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
version;Actual behavior
splitUnknownLtmSettings(S/settings.ts:24-44) handles onlyunrecognized_keysat the root of the file (issue.path.length === 0). Every other issue goes on toschema.parseinreadLtmSettingsFile(:46-53), which throws.The four files the loader serves have nested strict objects and enums in
SH/schema.ts:config/settings.json:sourcesAvailabilityModesis a list of modes.longTermMemoryBudgetTokens128–16,384 (:79) and the retention days 1–3,650 (:1359-1366).config/extraction.json:reasoningEffort,verbosity,promptTemplates[]andactivePromptTemplateIdsByMode.config/agent-settings.json:importSource.config/retention.json.Every reader fails on such a file:
selfCheckat activation (S/runtime.ts:15-25);S/persistence/storage.ts:244-250);getLtmGlobalSettings(S/settings.ts:54-57);getLtmExtractionConfig(S/extraction/extraction-config.ts:41);S/persistence/retention.ts:125);S/persistence/backup-restore.ts:38-41).The writers re-add only top-level unknown keys:
S/settings.ts:79;S/extraction/extraction-config.ts:97-98;S/persistence/storage.ts:249.If only the loader is fixed, the first activation (
storage.ts:244-250rewritessettings.jsonandretention.json) and the next save of an unrelated field would remove the newer nested values from disk.Measurement
A private probe (27 checks) writes newer-version fixtures into temporary roots. The first fixture holds:
sourcesAvailabilityModeswith a fourth mode"adventure";reasoningEffort: "xhigh";descriptionfield;activePromptTemplateIdsByMode.adventure;importSource: "worldbooks";A second fixture (checks 14a-15b) holds values outside this version's range:
longTermMemoryBudgetTokens: 99999;longTermMemoryMaxChunks: 0;maxOutputTokens: 100000;receiptRetentionDays: 100000.Two more cases are expected to keep failing: a 20,001-character template prompt, and 51 templates with one active.
For each fixture the probe activates the root, reads, saves, exports and restores.
stagingb1873710fOn
staging, the 17 failures include:too_big at sourcesAvailabilityModes,invalid_enum_value at sourcesAvailabilityModes.3);invalid_enum_value at reasoningEffort,unrecognized_keys at promptTemplates.0andat activePromptTemplateIdsByMode);invalid_enum_value at importSource);too_big at receiptRetentionDays), and the global settings read (too_big at longTermMemoryBudgetTokens,too_small at longTermMemoryMaxChunks,too_big at longTermMemoryStopWords.1);Seven of the 10 checks that pass on
stagingare guards that must keep passing:versionfail;retrievalblock restores;The other three (3, 9 and 14c) pass only because activation failed before it could rewrite anything, or because the request replaced the bad value.
With the prototype, these regressions pass on both trees:
tests/long-term-memory-storage.regression.ts(including the #1415 block);-runtime;-routes;-routes-backup.Strict
tsc(with a local strict config) shows the same 44 errors before and after.Steps to reproduce
config/extraction.jsonto{"version":1,"reasoningEffort":"xhigh"}, as a newer version might write it.invalid_enum_valueatreasoningEffort."description": "x"to an entry inpromptTemplates. The same failure appears withunrecognized_keys at promptTemplates.0."longTermMemoryBudgetTokens": 20000inconfig/settings.json, as a version with a higher limit might. Activation fails withtoo_big at longTermMemoryBudgetTokens.Minimal fix
One PR, patch bump. The finished patch, developed from the prototype measured above, touches 5 source files:
settings.tsgrows from 82 to about 180 lines, andextraction-config.ts,storage.ts,retention.tsandbackup-restore.tschange a few lines each.S/settings.ts:16-53: extendsplitUnknownLtmSettingsto work at any depth. It runssafeParseon a copy, up to 4 passes, and acts on three kinds of issue:unrecognized_keys: delete the keys. Root keys go tounknown, as today. A nested key's path is recorded in a newnewerlist.invalid_enum_value: an object field is deleted, so its default applies. A list entry is removed. A list left with no known entries is deleted, so the field loads its default.too_bigandtoo_small, for numbers, text and list lengths: removed the same way as an enum value. They are handled only in a pass with nothing else to remove, so a list first loses its newer entries and only then has its length checked. A 4-mode list with one new mode keeps its 3 known modes; it doesn't fall back as a whole.If the cleaned file still fails after a range fallback,
readLtmSettingsFilethrows the error for the file as stored. It names the range issue (too_big at promptTemplates.0.prompt), not what the fallback caused (Required, or the active-template rule).Any other issue still reaches
schema.parseand throws. That covers the wrong-type, wrong-shape andversioncases. The warning names the root keys and the dotted paths of thenewerentries once per file and set of names, never the values.Wrong types stay rejected, by choice. A newer version can raise a limit or add an option, and the field still means the same thing. A different type, though, would be a format change that needs a new
version, and a differentversionis rejected anyway. So a wrong type means a damaged or hand-edited file, and quietly using the default would hide that. Zod 3 reports a fraction where a whole number is expected asinvalid_type, so it stays rejected too (check 11).readLtmSettingsFilereturns{ settings, unknown, newer, raw }.S/settings.ts, newwithNewerLtmSettings(saved, read, request = {}, shown = {}): builds what a writer saves. It starts from{...unknown, ...saved}. Each newer value is then put back unless the request changed it. A request field equal to what readers were shown (shown, the resolved settings the GET returned) is unchanged:raw[field]);Three writers use it:
updateLtmGlobalSettings(S/settings.ts:65-82, write at:79), which compares stop words lowercased and without repeats, as the page saves them;updateLtmExtractionConfig(S/extraction/extraction-config.ts:71-104, read at:73, write at:97-98), with the parsedpatch, not the raw request, so a legacysystemPromptrequest is normalized first; it then drops any active-template choice whose template is not in the saved list, so a restored newer-mode choice never names a deleted template;S/persistence/storage.ts:248-249).S/persistence/retention.ts:125: when the retention file needed repair, the run returns{ ran: false, skippedNewerSettings: true }with one warning, throttled to once a day.Request bodies keep their strict schemas. Backup restore (
S/persistence/backup-restore.ts:128-186) stays strict, so a newer backup is still refused. Export writes only the values this version knows.Delete all (
S/persistence/backup-restore.ts:188-204) restores an empty export, which holds this version's fallbacks. It now reads the four settings files first and writes them back as stored into the staged vault, through a new optionalstoredargument ofreplaceLongTermMemoryData, so the newer values and the retention pause survive. The restore route passes none.CHANGELOG under
## Unreleased: one bullet. It also says retention pauses and what ends the pause.Not included
longTermMemoryRecallStyle: the global schema's preprocessor (SH/schema.ts:113-122) removes it before the loader sees it, so it loads the default and is not kept (as before).S/maintenance/legacy-adoption.ts:51-55. It parses the Engine's agent config, not a file a newer LTM wrote.Regression proof
One block in
tests/long-term-memory-storage.regression.ts, right after the #1415 block (:358); it fails onstagingat activation (too_big at receiptRetentionDays). It ports the probe's checks:PUT /settingsandPUT /extraction-settingsroutes, with one unrelated change or another mode's template, keeps every newer value;{ systemPrompt }request on a file with a newer template field saves a file that loads;2.5for a whole number), wrong shape andversion: 2still fail; request bodies with a newer or out-of-range value still fail;too_bigat that path;retrievalblock (maxVectorCandidates) restores, and a newer backup is still refused;Environment
stagingcheckout, unchanged)upstream/staging8b72729f1); measured on 1.4.54 (b1873710f)Logs, screenshots, or video
None. Both probe runs are summarized under Measurement; the raw results are kept privately.
Additional context
Tracker item RT-3 (runtime audit, finding 5, what remains after #1415). It extends the top-level design of #1415. The tracker counts 161
.strict()calls in the shared schemas. This fix doesn't remove any of them: they keep request bodies strict, and the loader tolerates newer values only for files.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: