mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #8831] [Issue]: Recent message tail is not a strict limit and Peek Prompt shows pre-summary counts #8516
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8516
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 @qvazzar on GitHub (Nov 4, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8831
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Recent message tailis configured to 10, butPeek Promptoften shows 12–24 history messages. The value is not enforced as a hard cap on the model-visible history. In addition,Peek Promptnormally shows the cached prompt from the last generation, which was captured before the post-generation summary ran.Expected behavior
If
Recent message tailis 10, then after summary processing completes, the prompt should contain at most the 10 protected recent messages plus any explicitly reported unsummarized backlog. If the backlog cannot be closed, the UI should say so instead of presenting the setting as a strict limit.Peek Promptshould distinguish:Actual behavior
The observed number of history messages in
Peek Promptvaries between roughly 12 and 24 even when the setting is 10. It changes from turn to turn and does not match the configured tail.Steps to reproduce
summaryContextSize(default is 50).Environment
Logs, screenshots, or video
Additional context
Why this happens
There are several contributing causes.
1. The tail is applied only when messages are hidden, not when the prompt is assembled
summaryTailMessagesis used bycomputeSummaryHideIdsin:packages/server/src/routes/generate/generate-route-utils.ts(around lines 840–855)That helper hides only messages covered by the current summary entry, minus the last
tailvisible messages. It is not consulted during prompt assembly.As a result, the model-visible history is closer to:
New messages that arrive between successful summary runs are not hidden until the next run. Because automatic summarization runs after the assistant reply, the cached prompt for that reply necessarily contains the pre-summary state.
2. The first automatic batch only covers the last
contextSizevisible messagesThe automatic summary path calls
selectRollingSummaryMessagesfrom:packages/server/src/routes/generate.routes.ts(around lines 11717–11721);packages/server/src/routes/generate/generate-route-utils.ts(around lines 981–1020).When there is no summary-owned hidden boundary yet, that helper returns:
So on a chat with more than
summaryContextSizevisible messages, the first automatic summary covers only the newestcontextSizemessages. Older visible messages are not included in the summary entry and therefore are not hidden bycomputeSummaryHideIds.Example:
Subsequent runs may reduce the old prefix when the visible count drops to
contextSizeor below, but with a large backlog, a small context window, or summary failures, the prefix can remain for many turns.3.
summaryContextSizecan be smaller than the backlogIf
summaryContextSizeis smaller than the total visible history, one automatic batch cannot cover everything. The engine needs an explicit catch-up/backfill path that starts from the oldest uncovered messages. Otherwise the oldest visible prefix is never summarized and never hidden.4.
summaryContextSize < summaryTailMessagesmakes hiding a no-opIf the summarizer window is smaller than the protected tail, every selected message falls inside the tail and
computeSummaryHideIdshides nothing. The UI currently does not warn about this combination.5.
Peek Promptprefers the cached prompt from the last generationThe cached prompt is saved in:
packages/server/src/routes/generate.routes.ts(around lines 10870–10879).The automatic summary runs later:
packages/server/src/routes/generate.routes.ts(around lines 14358+).POST /chats/:id/peek-promptreturns the cached prompt first:packages/server/src/routes/chats.routes.ts(around lines 3475–3519).That cached prompt describes the request that produced the reply, before the post-reply summary and hiding ran. It is expected to contain more messages than the current context. The UI currently presents it as the prompt without making that temporal difference obvious.
6. Other independent limits can change the observed count
ChatMetadata.contextMessageLimitin Advanced Parameters applies a separate history limit.computeSummaryHideIdstreats all visible roles as tail candidates, including narrator/system, while users often count only user/assistant messages.Suggested fixes
contextSizemessages.Recent message tailas a strict cap for covered messages, or rename and document it as a minimum protected tail.summaryContextSize < summaryTailMessages.Peek Promptdistinguish the cached request from a current live preview, and explain that later summaries are not reflected in the cached request.contextSize=50,tail=10→ after catch-up, 10 messages remain, not 24;contextSize < tail;Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Nov 4, 2026):
Taking this (SpicyMarinara, via Claude Code), branch
fix/recent-tail-strict.@SpicyMarinara commented on GitHub (Nov 4, 2026):
Fixed by #8841, merged into staging in
06f93787ba.