mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6148] A separate Game tool connection breaks the assistant prefill and doubles the [USER] marker in the narrator prompt #3421
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#3421
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/6148
Originally assigned to: @SpicyMarinara on GitHub.
When a Game chat is set to run its tool planning on a second connection, the prompt that gets sent to the narrator is built wrong in two ways. If you use an assistant prefill, the reply no longer continues from it: the message shows your prefill text followed by a reply that starts over from scratch. And if you have "Single user message" formatting on, the squashed transcript sent to the model now begins with two
[USER]lines instead of one. Neither shows an error, so the only way to notice is to open Peek Prompt.How to reproduce (try it yourself)
Shared setup for both cases:
Case 1, the prefill stops being the last turn:
*Gwen steadies her grip.*. Leave "Single user message" off.I force the gate.What you'll see: the message list ends with user, then assistant (your prefill), then another user message carrying the tool results. The prefill sits in the middle of the conversation instead of at the end. The saved narration begins with the prefill text, because the client already streamed it, but the model's reply starts a fresh sentence, so the prefill reads as a dangling fragment.
What should happen: the prefill is the last message the narrator sees and the reply continues from it, exactly as it does when "Game tool connection" is set back to "Same as narrator". Switch it back and replay the same turn to see the correct behavior.
Case 2, the doubled role marker:
What you'll see: the single squashed user block starts with two consecutive
[USER]lines before your first line of text.What should happen: one
[USER]line, the same as with "Same as narrator".Where it is
packages/server/src/routes/generate.routes.ts, the planner branch at lines 7318 to 7329:initialProviderMessagesis already the output ofprepareProviderMessages(same file, lines 6804 to 6806, and via thetoProviderMessagescallback at 6754 on the Advanced Memory path). The prefill is pushed as the last array element byappendGenerationTailMessagesinpackages/server/src/routes/generate/generate-route-utils.tslines 1042 to 1052. The non-idempotent line isgenerate-route-utils.ts:677, insidepostProcessMessages, which prefixes[ROLE]\nwith no check for a marker already present.What's happening
The planner branch takes a message array that has already been formatted and runs it through the formatter a second time, then appends the tool-results message to the very end. The second formatting pass re-prefixes the already-marked transcript, which is where the extra
[USER]line comes from. The append lands after the assistant prefill, which was the last element, so the prefill is no longer the trailing assistant turn the model is meant to continue. Meanwhile the prefill text has already been streamed into the message the user is watching (generate.routes.ts:6820 to 6824), and the de-duplication guard at :7605 only fires when the model repeats the prefill word for word, so the user ends up with prefill plus a restarted reply.The double pass changes the prompt in every formatting mode, not only under "Single user message": under the default formatting it also merges the tool-results message into the preceding user turn instead of leaving it as its own message.
Suggested fix
Build the narrator prompt the way the sibling post-roll continuation in the same file already does at lines 7979 to 7986:
await fitPromptForSend([...])only, with no secondprepareProviderMessagespass over already-prepared content. In the same edit, insert the tool-results message before the trailing assistant prefill rather than after it (or re-append the prefill afterwards), so the prefill stays the last turn. MakingpostProcessMessagesidempotent is worth doing too, but on its own it only fixes the marker half; the ordering still needs the insert-before.Context
Introduced by merged PR #5982, which implemented feature request #5957 (running Game tool calls on a different connection than narration). It is unreleased on staging: the latest release tag is v2.4.4. PR #6137 did not touch this area; its
generate.routes.tshunks land nowhere near the planner region, and the Peek Prompt work it did for #6130 is confined toPeekPromptModal.tsx. Closed issue #1461 ("Peek Prompt and generation use inconsistent prompt formatting parameters") is the closest conceptual relative of the double-formatting half. The shippedgame-tool-controlsregression lane passes because it never sets an assistant prefill and never enables "Single user message".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: #6150 (the planning instruction being hoisted into the system prompt on Claude and Gemini); #6155 (the stale tool_calls finish reason from the same planner path).
@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.