mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6149] Raw tool call text can appear in Game narration when a separate Game tool connection is used with a local model #3422
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#3422
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/6149
Originally assigned to: @SpicyMarinara on GitHub.
In a Game chat where the narrator runs on a local model and a separate connection is chosen to handle tools, the Game Master's story text can come back with a literal
<tool_call>{"name": "roll_dice", "arguments": {...}}</tool_call>block sitting in the middle of the prose. It stays in the saved message, so it is still there after a reload. The dice themselves still resolve correctly on the tool connection, so the leaked block is a stray duplicate of a roll that already happened, not a lost action.How to reproduce (try it yourself)
I try to force the gate.What you'll see: clean narration, a dice result, no raw JSON. This is the correct behavior.
I try to force the gate.again, and repeat for a few turns if the first one comes back clean.What you'll see: on turns where the local model takes the bait, the saved Game Master message contains a literal
<tool_call>{"name": "roll_dice", "arguments": {"notation": "1d20"}}</tool_call>string inside the story text. Reload the chat and it is still there.What should happen: the narration should contain only prose plus the dice result that the tool connection already rolled, with no tool call syntax visible.
How often it shows depends on the model: the leak is intermittent because the same prompt also hands the narrator the finished results and tells it not to reroll. The underlying prompt defect is on every turn in this configuration. Roleplay mode is not affected.
Where it is
At staging
ac14dd704:packages/server/src/routes/generate.routes.ts:5240-5251,appendLocalEndpointTools. Its early return at :5241 isif (!toolsAttached || !definitions?.length || conn.treatAsLocalEndpoint !== "true") return;, with no check for a Game tool connection. It injects the<available_functions>block that instructs the model to emit<tool_call>blocks.packages/server/src/routes/generate.routes.ts:7429-7432, the narration branchif (!responderToolsAttached || gameToolPlan), which routes narration through the streamingprovider.chatgenerator.packages/server/src/services/llm/providers/openai.provider.ts:1652-1654and:1851-1853, the only twoparseTextualToolCallscall sites, both insidechatCompleteand both gated onoptions.tools?.length. The streaming generator at:1176does not parse.What's happening
The narrator's system prompt still gets the local endpoint instruction block telling it to write
<tool_call>JSON, even though a separate connection is doing the tool work. When a Game tool connection is set, narration is streamed through the generator path, and that path is the one place that never parses textual tool calls. So the model is asked for a syntax that nothing downstream consumes, and whatever it emits is streamed straight into the saved message. Nothing on the server or the client strips it afterwards.The path is doubly blocked: even if narration went through
chatCompletehere, the options object built atgenerate.routes.ts:6921-6944carries notoolskey, and both parser call sites require one.Suggested fix
Stop injecting the block instead of trying to parse it, since on this path the tools deliberately belong to the planner connection. Skip
appendLocalEndpointToolswhenever a Game tool connection is set, which is a|| gameToolConnectionadded to the existing early return atgenerate.routes.ts:5241. That mirrors the guard the same feature already applies to the native tool channel,tools: gameToolConnection ? undefined : responderToolDefsat:6743,:6783and:6797. After the change, the narrator prompt should still carry<available_functions>with no Game tool connection set, and should not carry it when one is set.Worth pinning with regression coverage:
game-tool-controls.regression.tsuses a plain OpenAI narrator with no local endpoint flag, so it passes while this defect is live and would not catch a reintroduction.Context
Introduced by the Game tool planning work in PR #5982, which implemented feature request #5957. The narration branch condition
if (!toolsAttached || gameToolPlan)came in with commit5e41bf8ff; before it, a local endpoint Game narrator with tools attached always went throughchatComplete, where the injected block was parsed. This also means the textual tool call handling added for #2792 is inert on the new path. PR #6137 did not touch this area: its only Game tool connection changes are the Peek Prompt planner accounting for #6130, and both cited call sites are byte identical at the new head, only renumbered. Unreleased on staging, it landed after v2.4.4.Found by an AI-assisted sweep and re-verified against staging
ac14dd704on 2026-09-13. Please verify before fixing.@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.