mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6150] The Game tool planning instruction ends up inside the system prompt on Claude and Gemini connections #3425
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#3425
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/6150
Originally assigned to: @SpicyMarinara on GitHub.
When a Game chat uses a separate connection for tool planning, the engine sends that connection a short instruction telling it to plan tools and not write narration. On Anthropic and Google connections that instruction does not arrive where it was meant to: it gets folded into the system prompt, right after the Game Master prompt that says to output only scene text. The planner then tends to return fewer tool calls, no tool calls, or prose that is thrown away, and the turn quietly gets no tool work.
How to reproduce (try it yourself)
I try to pick the lock.[game/tools] Planning prompt sent to <name>, then find the provider's own outbound request body, for example[debug/anthropic] final tool request.What you'll see: the engine's own log shows the planning instruction as the last message, but the request that actually goes out has the text "You are planning tools for the Game narrator..." inside the top-level
systemfield (Anthropic) orsystemInstructionfield (Google), concatenated after the Game Master prompt. The conversation itself ends with the player's line.What should happen: the planning instruction should be the model's last input on every provider, the way it already is on an OpenAI-family connection. Repeat the same turn with an OpenAI tool connection to see the intended shape.
Where it is
packages/server/src/services/generation/game-tool-planning.ts, lines 36 to 45: the planning instruction is appended to the message array withrole: "system", relying on being last.packages/server/src/services/llm/providers/anthropic.provider.ts,chatCompleteat lines 369 to 381: every system message is filtered out of the conversation and joined into the top-levelsystemfield, with no positional condition.packages/server/src/services/llm/providers/google.provider.tsat line 625 and lines 650 to 652 does the same intosystemInstruction.What's happening
The planning pass depends on message position, but two of the three provider families do not preserve position for system messages: they hoist all of them into a single system block. So the instruction that is supposed to be the last thing the model reads becomes an extra paragraph appended to the narration system prompt, competing with "output only the VN scene text" instead of overriding it. Only OpenAI-family connections keep it as the final message. Anthropic and Google connections are exactly the ones a user is most likely to pick as a tool-capable planner, so the failure hits the common case, and because it is soft (fewer tool calls, or discarded prose) it is easy to misread as "the planner just does not work well on Claude".
Suggested fix
Stop relying on trailing position for a system-role message. Send the planning instruction as the final
role: "user"turn, which no provider relocates, or put it deliberately at the front of the system block and make the planner prompt self-contained there. Either way the planner should see the same instruction placement on every provider family.A regression for this needs to assert on the array handed to the provider's own request builder, not at the
planGameToolCallsboundary. The currentgame-tool-controlslane only checks the last message before the provider is called, so it cannot see the relocation.Context
Left 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
game-tool-planning.tsor either provider file. Related: the separate defect on this same feature where the planner branch reformats the narrator prompt and appends the tool results after the assistant prefill.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: #6148 (the planner branch reformatting the narrator prompt and appending after the prefill).
@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.