mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 20:58:37 +07:00
[GH-ISSUE #1252] [Issue]: LTM prompt serializer drops chunks without refill and the budget ignores overhead #638
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#638
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 7, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1252
Originally assigned to: @Promansis on GitHub.
Summary
The recall budget fills to
maxTokenscounting chunk text only, then the prompt serializer adds its own overhead and drops items withpop()without refilling. A high-value chunk can be dropped while a smaller one that now fits is never reconsidered.Affected package
long-term-memory (
packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/budget.ts,prompt.ts,generation-injection.ts)Expected behavior
The serializer's overhead (preamble, framing, labels, escaping) is reserved in the budget, and when an item is dropped, previously skipped items that now fit are retried. Selected chunks are not silently lost after the budget accepted them.
Actual behavior
budget.ts:143-149fills tomaxTokenscounting chunk text only.prompt.ts:64-70re-fits in tier order from 6 tokens;prompt.ts:73-108doesselected.pop()until the prompt fits, with no refill.generation-injection.ts:170-173passes the samemaxTokensto both.Scenario (maxTokens 4096): the budget selects a (tier 1, 100 tokens), b (tier 3, 3895 tokens, top-scoring hit) and c (tier 3, 97 tokens). The serializer keeps a and b and skips c. Overhead pushes the total past 4096, so it pops b. The prompt ends with only a, and c is never reconsidered although it fits. Whenever the budget is filled near
maxTokens, the overhead guarantees at least one pop. On real sample runs at 256-512 token budgets, ~2-3 chunks per query were dropped after the budget had selected them. It does not trigger at the 4096 default with typical chunk sizes.Steps to reproduce
maxTokens.Environment
staging)src/)Logs, screenshots, or video
None. Full write-up: audit finding LTM-SCORE-05 (local
scratch/audits/ltm-recall-scoring.md, not tracked).Additional context
Proposed fix:
maxTokens.Template check