mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #946] [Issue]: LTM bounded candidate recovery and output slimming (I09, I12) #497
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#497
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 (Sep 19, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/946
Originally assigned to: @Promansis on GitHub.
Summary
Long-Term Memory discards an entire extraction when the provider reports an output-token limit, even if complete evidence units precede the truncated tail. A response exceeding the candidate cap likewise loses every candidate. Meanwhile, the generation contract requires per-unit IDs and source hashes that the server immediately replaces.
Implement bounded candidate recovery and output slimming together (phase 6, I09/I12): preserve complete, validated candidates as an explicitly incomplete draft and stop requiring redundant model-generated metadata.
Affected package
long-term-memory— package-owned server extraction and the directly affected shared accounting/schema contracts.Expected behavior
length,max_tokens, ortoken_limit, recover only syntactically complete objects from the top-levelunitsarray. Discard an unfinished candidate; never complete a string, field, nested value, or claim by guessing. Continue through existing identity, evidence, scope, deduplication, and graph validation.LTM_EXTRACTION_MAX_CANDIDATES(currently 999) provider candidates in their original order. Report overflow without failing the whole extraction; keep rejection details bounded byLTM_EXTRACTION_MAX_REJECTION_DETAILS(currently 80).idandsourceHashfrom the model generation fields and response schema. Preserve the server's deterministic ID and authoritative source hash. If evidence is omitted, populate it from the trusted source-note context before schema validation; explicitly supplied invalid evidence must still fail the existing checks.Actual behavior
Confirmed by source inspection at
aa2b391e1cfc3b86bcc68d6f82412a8364ac9b43:runLongTermMemoryEvidenceUnitExtraction()throwsltm_model_output_truncatedbefore parsing any content for all three token-limit finish reasons.parseEvidenceUnitPayload()throws wheninput.units.length > 999; the extraction wrapper converts this toltm_model_output_unusable.evidenceUnitResponseFormat()requiresid,sourceHash, andevidence.normalizedEvidenceUnitRecord()already replaces the first two, but does not supply omitted evidence.evidenceUnitMessages().unitFieldsalso asks for these fields.strict: false, conditionalallOf/if/then/notblocks, and optional properties. Removing conditionals alone does not establish strict-provider compatibility.Steps to reproduce
The following are synthetic regression cases to execute during implementation; they were derived from source and existing fixtures, not run for this issue:
tests/long-term-memory-extraction-reliability.regression.ts. Return an envelope with one complete, otherwise-valid unit followed by an unfinished second object, withfinishReason: "length". Current code throws before considering the complete unit. A fully valid envelope with the same finish reason also throws.unitsarray of 1,000 candidates withfinishReason: "stop". Current code rejects the whole response with the maximum-candidate error. This rejection is already asserted in both extraction reliability and extraction graph suites.evidenceUnitResponseFormat()and the generatedunitFields: both request metadata overwritten server-side. Omitevidencefrom an otherwise-valid candidate and the current per-unit schema rejects it before a trusted-source default can be supplied.Environment
>=2.4.1 <4.0.0andbuiltAgainst.engineVersion: 2.4.1.1.3.4in the inspected manifest.staging.Logs, screenshots, or video
No live-provider logs, private chat data, or screenshots were used. Evidence is code and existing test assertions, not an executed reproduction.
Let
ltm/meanpackages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/andshared/meanpackages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memory/.ltm/evidence-unit-extraction.ts:274–402,483–510,712–762ltm/evidence-unit-extraction.ts:935–964,1124–1147ltm/source-extraction.ts:520–595ltm/source-processing.ts:75–84,242–262shared/schema.ts:806–829,2092–2173tests/long-term-memory-extraction-graph.regression.ts:822–848;tests/long-term-memory-extraction-reliability.regression.ts:98–149GitHub comparison against upstream
stagingat40fe81f61c7150e73e15e80a4938986f9d2390ccshowed one additional commit and no changes to the LTM package, referenced tests, issue templates, or contribution guidance. Focused issue/PR searches found no matching outstanding recovery/output-slimming work.Additional context
Validated scope and implementation constraints
canMarkCurrent()currently permitspartial_successwith zero drops for clean deduplication. Carry the token-limit/overflow signal through normalization, compilation, draft finalization, and single/batch processing, using the smallest existing mechanism that preserves this distinction. Do not manufacture a candidate rejection solely to encode an unknown truncated tail.providerCandidates + normalizedAdditions == parserRejections + validationRejections + deduplications + keptUnits. Simply slicing the array and passing the original count downstream will still fail. Define explicit bounded overflow reporting, preserve truthful counts and balance, and keep draft/API persistence valid. Test structured backfill combined with near-cap provider input. Do not silently clamp away discarded work or raise the processing cap as the fix.strict: truealone. Preserve the merged independent response-format/reasoning fallbacks.unitFieldswith the schema. Free-form extraction/summary prompt edits and the finalDEFAULT_LTM_EXTRACTION_PROMPTconstants pass remain outside this issue. Current packaged prompts still instruct the model to emit evidence/source hashes; record that limitation and coordinate the maintainer's Engine prompt updates before claiming end-to-end token savings.Acceptance and regression proof
Primary regression owners:
tests/long-term-memory-extraction-reliability.regression.tsandtests/long-term-memory-extraction-graph.regression.ts. Extend the existing source/finalization cases and the focused imports/drafts cases intests/long-term-memory-routes.regression.tswhere needed for persistence and API proof.Before implementation, complete Marinara Start/resume and establish the contract-sensitive baseline in the issue-linked workspace. Run the focused regressions first, then the required LTM and repository gates, rebuild the affected package/catalog through their builders, and verify the resulting artifact. No tests, builds, provider calls, install checks, or implementation edits were performed for this issue validation.
Baseline dependencies are already merged: #898 (source update fixes), #920 (context/freshness handling), and #938 / #935 (independent provider fallbacks and output viability). Preserve those behaviors; do not reimplement them. Exclude retryability cleanup, batch caching, identity repair, prompt redesign, and new recovery services from this phase.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: