[PR #8172] [MERGED] fix(game): retell a textless tool round for Claude, lift a written-out plan off the scene, roll harm into the sheet in one-request turns, name the right who #8139

Closed
opened 2026-10-24 04:10:43 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8172
Author: @kolacheee
Created: 10/23/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @kolacheee

Base: staging ← Head: claude/project-thread-nibhp6


📝 Commits (9)

  • 236ea56 fix(game): retell a textless tool round for Claude, lift a written-out plan off the scene, put rolled harm on the sheet in one-request turns
  • 1382ba9 fix(game): lift a written-out plan only when it is one, after leading blank lines, and never from the player's own line
  • 9a4b798 fix(game): judge each leading paragraph on its own label before lifting it as a plan
  • 9dbcaf3 docs(game): say what the planning label admits, not what it lifts
  • 08d520b fix(game): lift a plan's whole leading run, whichever paragraph names it a plan, and stop at an answer
  • 0a35558 fix(game): keep a question or answer behind a plan with the scene
  • b879234 fix(game): tell the Game Master a sheet command's who is the one the harm happens to
  • 2de0b0e Merge remote-tracking branch 'origin/staging' into claude/project-thread-nibhp6
  • 0cb3103 fix(game): name the payer of a spent resource as its who, and the player only when the player paid

📊 Changes

5 files changed (+363 additions, -6 deletions)

View changed files

📝 packages/server/src/routes/generate.routes.ts (+10 -0)
➕ packages/server/src/services/game/gm-planning.ts (+39 -0)
📝 packages/server/src/services/game/gm-prompts.ts (+10 -4)
📝 packages/server/src/services/llm/providers/openai.provider.ts (+96 -2)
📝 scripts/regressions/game-gm-turn-roller-party.regression.ts (+208 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #8171

Why this change

A re-test of #8165 with a real Game Master still lost turns with 400: Invalid Anthropic Messages API request. The GM was Claude through an OpenAI-compatible endpoint that hands requests to Anthropic, with thinking on. The round whose replayed roll_dice turn had text went through, and both rounds whose turn had none were refused.

The re-test found three more problems:

  • The GM wrote its plan as prose before the scene, and that plan was saved as narration.
  • In a one-request turn, a burn the player asked to have rolled never reached HP, because in that mode a rolled amount had no way into a sheet command.
  • A fall's damage was put on the wrong character's sheet.

What changed

  • Textless tool rounds: for a Claude model, an assistant tool-call turn with neither text nor signed thinking is retold as text. This also applies under a proxy alias such as opus-5-5.
    • The turn's calls are dropped, and its results become one user message.
    • Rounds with text or signed thinking stay native, and unsigned reasoning is dropped.
    • Any Chat Completions endpoint whose 400 names Anthropic is retried once in that shape, so a model id that hides Claude still works.
  • Written-out plans: in Game Mode, a reply's leading run of planning paragraphs is moved into the turn's thinking. The run must name itself a plan (Opening scene:, Plan:), may include Location:, Setting: or Beats: paragraphs, and is moved only when narration follows.
    • A paragraph that could be an answer or a question to the player ends the run and stays visible: Notes:, Checks:, Approach:, Goals:, Outline: and Next steps:.
    • The player's own impersonated line is never touched.
    • The GM reminder now says the first words belong to the scene.
  • Rolled harm in one-request turns: in a ruleset game, the GM is told to put the roll in the sheet command's amount (amount="[[roll: 1d6]]"). The placeholder pass already fills it in before the sheet pass reads the command, and the prompt's "never inside another tag" rule now makes that one exception.
  • The right who: the sheet rules now say a command's who is the one the narration names. That is whoever takes the harm or the healing, or whoever pays the resource, and it is the player only when the player is the one. The GM is told to check it against the narration, not against whoever acted or spoke last.

Validation

  • Server typecheck, prettier
  • Full regression suite (see the comment below for the count)
  • Extended game-gm-turn-roller-party:
    • Textless rounds are retold for claude-opus-5-5, opus-5-5 and anthropic/sonnet-5.
    • Rounds with signed thinking stay native, and DeepSeek is unchanged.
    • An Anthropic 400 from a non-Claude id is retried once in the new shape, against a local server.
    • Plan lifting is checked whole and mixed. Answers, questions and narration that only look like labels are left alone.
    • The one-request sheet line, the who line, and a placeholder filled inside a sheet command.
  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • The laptop playtest's request logs pinned the 400: the refused requests were the only ones whose replayed tool-call turn had empty content. The playtest will re-test against the real connection.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

None: this changes server-side request shape, prompt text and saved content.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8172 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `claude/project-thread-nibhp6` --- ### 📝 Commits (9) - [`236ea56`](https://github.com/Pasta-Devs/Marinara-Engine/commit/236ea56842c858fba5466949a7b5298914f7f756) fix(game): retell a textless tool round for Claude, lift a written-out plan off the scene, put rolled harm on the sheet in one-request turns - [`1382ba9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1382ba93ef3c0dd8768486fec3f3e1288f3d11a2) fix(game): lift a written-out plan only when it is one, after leading blank lines, and never from the player's own line - [`9a4b798`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9a4b798a639cf44bf83451f61f0a45e399cf784a) fix(game): judge each leading paragraph on its own label before lifting it as a plan - [`9dbcaf3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9dbcaf343cff4fedf92d54eaafbccdc6a36c9e58) docs(game): say what the planning label admits, not what it lifts - [`08d520b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/08d520b59790ad86f1249a659795730f4ecb7e05) fix(game): lift a plan's whole leading run, whichever paragraph names it a plan, and stop at an answer - [`0a35558`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0a35558cfb34f38d6493d87276ae0cbdd34d1b12) fix(game): keep a question or answer behind a plan with the scene - [`b879234`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b87923485ab2cbc3adcad9870bd7c6234bc2c774) fix(game): tell the Game Master a sheet command's who is the one the harm happens to - [`2de0b0e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2de0b0e7cdf77e1723f9d8d68c2f9a0d55aca8b4) Merge remote-tracking branch 'origin/staging' into claude/project-thread-nibhp6 - [`0cb3103`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0cb31037a02926d7fe0c18fc45a0f905dc5b5b7c) fix(game): name the payer of a spent resource as its who, and the player only when the player paid ### 📊 Changes **5 files changed** (+363 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate.routes.ts` (+10 -0) ➕ `packages/server/src/services/game/gm-planning.ts` (+39 -0) 📝 `packages/server/src/services/game/gm-prompts.ts` (+10 -4) 📝 `packages/server/src/services/llm/providers/openai.provider.ts` (+96 -2) 📝 `scripts/regressions/game-gm-turn-roller-party.regression.ts` (+208 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #8171 ## Why this change A re-test of #8165 with a real Game Master still lost turns with `400: Invalid Anthropic Messages API request`. The GM was Claude through an OpenAI-compatible endpoint that hands requests to Anthropic, with thinking on. The round whose replayed `roll_dice` turn had text went through, and both rounds whose turn had none were refused. The re-test found three more problems: - The GM wrote its plan as prose before the scene, and that plan was saved as narration. - In a one-request turn, a burn the player asked to have rolled never reached HP, because in that mode a rolled amount had no way into a sheet command. - A fall's damage was put on the wrong character's sheet. ## What changed - **Textless tool rounds:** for a Claude model, an assistant tool-call turn with neither text nor signed thinking is retold as text. This also applies under a proxy alias such as `opus-5-5`. - The turn's calls are dropped, and its results become one user message. - Rounds with text or signed thinking stay native, and unsigned reasoning is dropped. - Any Chat Completions endpoint whose 400 names Anthropic is retried once in that shape, so a model id that hides Claude still works. - **Written-out plans:** in Game Mode, a reply's leading run of planning paragraphs is moved into the turn's thinking. The run must name itself a plan (`Opening scene:`, `Plan:`), may include `Location:`, `Setting:` or `Beats:` paragraphs, and is moved only when narration follows. - A paragraph that could be an answer or a question to the player ends the run and stays visible: `Notes:`, `Checks:`, `Approach:`, `Goals:`, `Outline:` and `Next steps:`. - The player's own impersonated line is never touched. - The GM reminder now says the first words belong to the scene. - **Rolled harm in one-request turns:** in a ruleset game, the GM is told to put the roll in the sheet command's amount (`amount="[[roll: 1d6]]"`). The placeholder pass already fills it in before the sheet pass reads the command, and the prompt's "never inside another tag" rule now makes that one exception. - **The right `who`:** the sheet rules now say a command's `who` is the one the narration names. That is whoever takes the harm or the healing, or whoever pays the resource, and it is the player only when the player is the one. The GM is told to check it against the narration, not against whoever acted or spoke last. ## Validation - [x] Server typecheck, prettier - [x] Full regression suite (see the comment below for the count) - [x] Extended `game-gm-turn-roller-party`: - Textless rounds are retold for `claude-opus-5-5`, `opus-5-5` and `anthropic/sonnet-5`. - Rounds with signed thinking stay native, and DeepSeek is unchanged. - An Anthropic 400 from a non-Claude id is retried once in the new shape, against a local server. - Plan lifting is checked whole and mixed. Answers, questions and narration that only look like labels are left alone. - The one-request sheet line, the `who` line, and a placeholder filled inside a sheet command. - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - The laptop playtest's request logs pinned the 400: the refused requests were the only ones whose replayed tool-call turn had empty content. The playtest will re-test against the real connection. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) None: this changes server-side request shape, prompt text and saved content. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:10:43 +07:00
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#8139
No description provided.