[GH-ISSUE #6147] A Game turn that rolled real dice can tell the rewrite step that no dice were rolled #3420

Closed
opened 2026-10-21 06:02:55 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Sep 13, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6147

Originally assigned to: @SpicyMarinara on GitHub.

On a connection with tool support, a Game turn can throw a real die, show its dice card, and then send a follow-up request that tells the model "No dice were rolled." The model is asked to rewrite the whole narration on that basis, so the new prose can end up disagreeing with the dice card sitting on the same message.

How to reproduce (try it yourself)

  1. Open a Game Mode chat on a connection with native tool support (OpenAI, for example). Leave the Game tool connection in Chat Settings unset. The roll_dice tool attaches by itself on Game turns, so nothing else needs enabling.
  2. In the Game Master instructions (or an author's note) add, verbatim: When the player attacks, call roll_dice for the attack and do not write its number as a [skill_check:] record. Request the damage by writing exactly [dice: 4d6kh3] in your narration and write no numbers yourself.
  3. Send: I swing my greatsword at the ogre.
  4. Watch the turn. A dice card for the attack roll appears mid turn, then the narration is replaced by a rewritten version.
  5. Open Peek Prompt (or the Logs) and read the final user message of the second request, the one that rewrites the turn with the real results.

What you'll see: that request reads The engine has now rolled the requested dice: followed by No dice were rolled., and then lists 4d6kh3 as unreadable notation. Meanwhile the attack roll's dice card is on the swipe and its result is in the Logs. The model is told nothing was rolled and asked to re-author the narration around that.

What should happen: the list should name every roll the turn keeps, including the roll_dice result, so the rewrite is done with the numbers the player can actually see.

A milder version of the same bug: swap the unreadable request for a readable one such as [dice: 3d6]. The follow-up then fires and lists only the 3d6 damage. The attack roll's notation and total still appear nowhere in the request, while its card stays on the swipe.

Worth knowing before trying: if the Game Master echoes the tool roll as a complete [skill_check: ... rolls=... total=... result=...] record, which its own instructions ask it to do, nothing goes wrong. Either no rewrite fires at all, or the echoed numbers do reach the list. The problem only appears on mixed turns where a real tool roll is not written up as a record.

Where it is

Staging ac14dd704, packages/server/src/routes/generate.routes.ts, the Game outcome rewrite block:

  • :7974-7978 resolvedSummary is built from exactly three arrays: rolled.results, generalRolls.checkResults, generalRolls.diceRolls. toolDiceRollResults is not one of them.
  • :7984 the prompt line The engine has now rolled the requested dice:\n${resolvedSummary || "No dice were rolled."}.
  • :7970 the gate, now if (rolled.resolved || generalRolls.rolled || generalRolls.unresolved.length || rolled.sparse).
  • :6961 let narratorMessages = initialProviderMessages;, reassigned only inside the if (gameToolPlan) branch at :7318, so on the ordinary tool loop the follow-up prompt contains no tool call and no tool result.
  • :8500 extraUpdate.diceRollResults = [...retainedRolls, ...toolDiceRollResults];, which is where those same tool rolls get saved onto the swipe.

What's happening

The rewrite's result list is assembled only from dice the engine rolled for text tags. Dice thrown through the roll_dice tool live in a separate list that the summary never reads, even though that list is what gets persisted on the message and drawn as cards. When the turn's only text tag is unreadable notation, the summary comes out empty, and the empty-summary fallback string states that no dice were rolled. The rewrite prompt is also built from the pre-tool message list, so the tool round itself is not in context either.

Suggested fix

Feed the tool rolls into the summary: add the toolDiceRollResults entries that were not already echoed as records to resolvedSummary at :7974-7978. That fixes both halves at once, since a non-empty summary also stops the No dice were rolled. fallback from firing on a turn that rolled dice.

Please do not build the follow-up on the tool loop's message list instead. That list carries tool role entries and assistant tool calls, and the follow-up goes through the text-streaming provider.chat interface. The codebase's own pattern for getting tool results into that path is to flatten them into a user message, which is what the gameToolPlan branch does at :7319-7322.

Worth pinning with the first case in scripts/regressions/game-text-dice.regression.ts that attaches native tools. Every assertion in that lane today asserts options.tools === undefined, and its unsupported-notation case at :121-126 pins No dice were rolled as correct, so the lane structurally cannot see this shape.

Context

The missing tool rolls date to PR #5979 (issue #5961), which added the outcome rewrite for text tags. PR #6137 touched both generate.routes.ts and dice.service.ts but not this mechanism, and one sub-case got worse: the fix for #6128 widened the rewrite trigger to include unreadable notation and added the No dice were rolled. fallback string, so a turn that rolls a real die and also writes unreadable notation now fires a follow-up that states no dice were rolled. Before #6137 that turn fired no follow-up at all. Related but different code paths: #6118 (the separate Game tool connection branch losing verbs) and #6127 (what happens when the follow-up request fails).

Unreleased on staging: this landed after v2.4.4.

Found by an AI-assisted sweep and re-verified against staging ac14dd704 on 2026-09-13. Please verify before fixing.

Originally created by @kolacheee on GitHub (Sep 13, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6147 Originally assigned to: @SpicyMarinara on GitHub. On a connection with tool support, a Game turn can throw a real die, show its dice card, and then send a follow-up request that tells the model "No dice were rolled." The model is asked to rewrite the whole narration on that basis, so the new prose can end up disagreeing with the dice card sitting on the same message. ## How to reproduce (try it yourself) 1. Open a Game Mode chat on a connection with native tool support (OpenAI, for example). Leave the Game tool connection in Chat Settings unset. The `roll_dice` tool attaches by itself on Game turns, so nothing else needs enabling. 2. In the Game Master instructions (or an author's note) add, verbatim: `When the player attacks, call roll_dice for the attack and do not write its number as a [skill_check:] record. Request the damage by writing exactly [dice: 4d6kh3] in your narration and write no numbers yourself.` 3. Send: `I swing my greatsword at the ogre.` 4. Watch the turn. A dice card for the attack roll appears mid turn, then the narration is replaced by a rewritten version. 5. Open Peek Prompt (or the Logs) and read the final user message of the second request, the one that rewrites the turn with the real results. **What you'll see:** that request reads `The engine has now rolled the requested dice:` followed by `No dice were rolled.`, and then lists `4d6kh3` as unreadable notation. Meanwhile the attack roll's dice card is on the swipe and its result is in the Logs. The model is told nothing was rolled and asked to re-author the narration around that. **What should happen:** the list should name every roll the turn keeps, including the `roll_dice` result, so the rewrite is done with the numbers the player can actually see. A milder version of the same bug: swap the unreadable request for a readable one such as `[dice: 3d6]`. The follow-up then fires and lists only the 3d6 damage. The attack roll's notation and total still appear nowhere in the request, while its card stays on the swipe. Worth knowing before trying: if the Game Master echoes the tool roll as a complete `[skill_check: ... rolls=... total=... result=...]` record, which its own instructions ask it to do, nothing goes wrong. Either no rewrite fires at all, or the echoed numbers do reach the list. The problem only appears on mixed turns where a real tool roll is not written up as a record. ## Where it is Staging ac14dd704, `packages/server/src/routes/generate.routes.ts`, the Game outcome rewrite block: - `:7974-7978` `resolvedSummary` is built from exactly three arrays: `rolled.results`, `generalRolls.checkResults`, `generalRolls.diceRolls`. `toolDiceRollResults` is not one of them. - `:7984` the prompt line `The engine has now rolled the requested dice:\n${resolvedSummary || "No dice were rolled."}`. - `:7970` the gate, now `if (rolled.resolved || generalRolls.rolled || generalRolls.unresolved.length || rolled.sparse)`. - `:6961` `let narratorMessages = initialProviderMessages;`, reassigned only inside the `if (gameToolPlan)` branch at `:7318`, so on the ordinary tool loop the follow-up prompt contains no tool call and no tool result. - `:8500` `extraUpdate.diceRollResults = [...retainedRolls, ...toolDiceRollResults];`, which is where those same tool rolls get saved onto the swipe. ## What's happening The rewrite's result list is assembled only from dice the engine rolled for text tags. Dice thrown through the `roll_dice` tool live in a separate list that the summary never reads, even though that list is what gets persisted on the message and drawn as cards. When the turn's only text tag is unreadable notation, the summary comes out empty, and the empty-summary fallback string states that no dice were rolled. The rewrite prompt is also built from the pre-tool message list, so the tool round itself is not in context either. ## Suggested fix Feed the tool rolls into the summary: add the `toolDiceRollResults` entries that were not already echoed as records to `resolvedSummary` at `:7974-7978`. That fixes both halves at once, since a non-empty summary also stops the `No dice were rolled.` fallback from firing on a turn that rolled dice. Please do not build the follow-up on the tool loop's message list instead. That list carries `tool` role entries and assistant tool calls, and the follow-up goes through the text-streaming `provider.chat` interface. The codebase's own pattern for getting tool results into that path is to flatten them into a user message, which is what the `gameToolPlan` branch does at `:7319-7322`. Worth pinning with the first case in `scripts/regressions/game-text-dice.regression.ts` that attaches native tools. Every assertion in that lane today asserts `options.tools === undefined`, and its unsupported-notation case at `:121-126` pins `No dice were rolled` as correct, so the lane structurally cannot see this shape. ## Context The missing tool rolls date to PR #5979 (issue #5961), which added the outcome rewrite for text tags. PR #6137 touched both `generate.routes.ts` and `dice.service.ts` but not this mechanism, and one sub-case got worse: the fix for #6128 widened the rewrite trigger to include unreadable notation and added the `No dice were rolled.` fallback string, so a turn that rolls a real die and also writes unreadable notation now fires a follow-up that states no dice were rolled. Before #6137 that turn fired no follow-up at all. Related but different code paths: #6118 (the separate Game tool connection branch losing verbs) and #6127 (what happens when the follow-up request fails). Unreleased on staging: this landed after v2.4.4. Found by an AI-assisted sweep and re-verified against staging ac14dd704 on 2026-09-13. Please verify before fixing.
bsakaguchi 2026-10-21 06:02:55 +07:00
Author
Owner

@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.

<!-- gh-comment-id:5654637073 --> @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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3420
No description provided.