mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6145] World generation silently cuts off a lore entry you picked, then reports it as fully included #3419
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#3419
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 @kolacheee on GitHub (Sep 13, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6145
Originally assigned to: @SpicyMarinara on GitHub.
When you tick a lorebook entry for world generation and that entry contains a macro such as {{personaDescription}}, the engine can cut the entry off part way through and still report it as included in full. Nothing is logged and nothing is flagged, so the world gets written from less lore than you chose.
How to reproduce (try it yourself)
What you'll see: The lore stops dead at 200,000 characters. GTAIL_MARKER_END is gone, along with roughly 48,000 characters of expanded persona text, about a fifth of the entry. No warning appears anywhere, and the reply's lorebook block still says includedEntries: 1 with an empty skippedEntries list.
What should happen: The whole entry reaches the model. If something really has to cut it, the entry is reported as skipped with a reason, never counted as included.
Two controls that pin the cause. Delete every {{personaDescription}} from the entry but keep the same size: the marker survives, which rules out entry size, the token budget and the context window. Shrink the filler so the resolved text lands under 200,000 characters (10 macros instead of 100): everything survives, expansions included.
Where it is
At staging
ac14dd704:packages/server/src/routes/game.routes.ts:10888, insideresolveLoreMacrosForFinal:maxMacroOutputLength: Math.max(value.length, 200_000), wherevalueis the entry text before macros expand.packages/shared/src/utils/macro-engine.ts:2387appliesclampMacroOutputto the fully expanded string. Lines 273 to 276 are a bare slice with no signal, and line 157 isMAX_MACRO_OUTPUT_LENGTH = 200_000.packages/server/src/routes/game.routes.ts:11175-11184buildsskippedEntriesonly from the token budget skips, so a macro clamp cut has no path into it.CHANGELOG.md:62ships the sentence "Every eligible entry you select is included in full."What's happening
The ceiling handed to the macro resolver is computed from the entry's length before macros expand, but the clamp is applied afterwards, to the expanded text. Headroom is therefore max(0, 200,000 minus the raw entry length): an entry of 200,000 characters or more gets none at all, and a smaller entry gets only whatever is left of a flat 200,000, which 100 copies of a 2,000 character persona description blow straight through. The boundary is not at 200,000 raw characters either: a 199,900 character entry that grows by about 2,000 characters truncates too. The clamp then simply slices the string and returns it, so nothing downstream can learn that anything was lost, and the entry is still counted in includedEntries.
Suggested fix
Two parts, and both are needed. Resizing the ceiling alone still truncates silently at some larger size, and a diagnostic alone leaves the loss in place.
value.length + 200_000keeps the runaway expansion guard that the call site comment says it is retaining, and removes the discontinuity.clampMacroOutputshould mark the budget as exceeded so the route can move the entry intoskippedEntrieswith ablockedBynaming the macro clamp, or fail the call the way an over context selection already does. Returning a short string and then counting the entry as included is the invisible budget failure this feature was built to remove, relocated from the token budget into the macro clamp.There is no coverage today.
scripts/regressions/experience-lore-entries.regression.ts:704-718asserts that a huge selection must arrive whole, but its content carries no macros, so the lane passes at head with this live. A macro carrying twin of that assertion is worth adding, asserting on the clamp signature (the lore section length equals the raw entry length, or exactly 200,000) rather than on a short end marker.One thing to keep out of scope: every other
resolveContentcaller passes no override and clamps at a flat 200,000 with the same silence. That app wide question is older and larger, and deserves its own issue if you want it.Context
Introduced by PR #5977, which closed issue #5953 ("World generation shouldn't cap how much lorebook a player can feed it"). That PR removed the 3,000 token EXPERIENCE_LORE_TOKEN_BUDGET, which used to refuse an oversized entry with a named skip record, and added the maxMacroOutputLength option in its place, so on this route an honest refusal became a silent cut. #5953 argues the opposite of the current behavior: "there's no per-entry content cap... The first real wall is the model's own context window." PR #6137 did not touch this: its game.routes.ts hunks are the three sibling fixes from the same sweep (#6122, #6126, #6129), and macro-engine.ts is not in that diff at all. Unreleased on staging, the latest release tag is v2.4.4.
Found by an AI-assisted sweep and re-verified against staging
ac14dd704on 2026-09-13. Please verify before fixing.Related issue from the same sweep: #6146 (the pre-call context check missing the reply schema on the same route).
@SpicyMarinara commented on GitHub (Sep 13, 2026):
Codex is addressing this report on behalf of @SpicyMarinara in draft PR #6168 as part of the requested issue sweep. I will verify the reported path against staging and preserve existing behavior outside the narrow fix.