mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1555] [Issue]: Long-Term Memory: an extraction answer cut off at the output limit loses its last memories on every retry #1544
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#1544
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/1555
Originally assigned to: @Promansis on GitHub.
Summary
When the extraction model's answer reaches the output token limit (default 8,192), Long-Term Memory keeps the complete memories written before the cut, marks the source incomplete and offers a retry. The retry sends the same request with the same limit, so it stops at the same place every time. The memories the model writes last are lost for good, usually recurring motifs, open threads and the tone note. Add an opt-in setting, "Finish cut-off answers", that asks the model for the rest of a cut-off answer, and tell users with the setting off why Retry won't help.
Affected package
long-term-memory1.4.80evidence-unit-extraction.ts), extraction settings, Memory Settings formExpected behavior
Actual behavior
The answer is cut, the salvaged memories are saved, the source is marked incomplete and retryable, and each retry is cut at the same place. The only message is "Extraction output was cut off by the model limit; the source remains retryable."
Steps to reproduce
Measured on 15 real chat summaries with Opus, Sonnet and Haiku as the extraction model at the default 8,192: 1 to 4 answers in 15 per model still pass the limit (worst about 11,200 tokens), losing 3 to 6% of the memories, always the ones written last.
Minimal fix
One PR, patch bump (1.5.0 is reserved for the planned migration release).
S =
packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory, H =packages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memory, C =packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory.false, added the wayaiKeywordExtractionis:H/schema/settings.ts(settings and resolved settings), the default inS/extraction/extraction-config.ts, passed through both extraction calls inS/extraction/source-extraction.ts.S/extraction/evidence-unit-extraction.ts, only when the setting is on. When the first answer is cut (finish reasonlength,max_tokensortoken_limit) and at least one memory was salvaged, call the model again with the same messages, the samemaxTokensand the same response format, plus acontinuationobject in the user JSON: an instruction to return only the memories not yet listed, starting with the interrupted stream, andalreadyExtracted: [{ bucket, subjectId, sectionKey, text }]with text cut to 100 characters. Append the new units and drop exact repeats. Repeat while the latest answer is still cut and added at least one unit, at most 3 continuation rounds. If a round adds nothing or the provider rejects the call, keep what is held and finish as today (incomplete, retryable). Record each round in the debug log (rounds, units added). An answer with nothing salvaged is unchanged: no extra call,ltm_model_output_truncated.ltm_model_output_incompletewarning says: "The answer stopped at the output limit, so Retry will stop at the same place. Turn on 'Finish cut-off answers' in Memory Settings to fetch the rest." With the setting on and the last round still cut, the warning keeps today's text.Togglebeside "Maximum output tokens" inC/settings/MemorySettings.tsx(form state as foraiKeywordExtraction), with two strings inC/locales/en.json:## Unreleased: a new setting in Memory Settings, "Finish cut-off answers", off by default; with it on, an extraction cut off at the output limit asks the model for the rest (up to 3 extra requests for that source); with it off, a cut-off source now says Retry will stop at the same place and names the setting.Not included
warninganderror; the debug log records the rounds.Regression proof
tests/long-term-memory-extraction-reliability.regression.ts, next to the existing recovered-truncation case:incomplete, and the warning names the setting.continuation.alreadyExtractedwith the salvaged unit; units are merged with exact repeats dropped;incompleteis false.ltm_model_output_truncated(the existing cases).tests/long-term-memory-storage.regression.ts: the new setting saves, reads back and defaults tofalsewhen absent.Environment
staging87d1ccadc)upstream/staging2a473d3eb)Logs, screenshots, or video
None. The measurement replayed cached answers from three models cut at 4,096 and 8,192 tokens and compared the stored memories by meaning:
Additional context
Tracker item EX-I13. Follows the extraction prompt clean-ups in #1512 and #1513, which made cut answers rarer but didn't remove them.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: