mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #3428] [CLOSED] Fix turn-game narration leaking model chain-of-thought into chat #5933
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#5933
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3428
Author: @Romuromylus
Created: 7/10/2026
Status: ❌ Closed
Base:
staging← Head:fix/turn-game-narration-thinking-leak📝 Commits (1)
c78c76cFix turn-game narration leaking model chain-of-thought into chat📊 Changes
2 files changed (+29 additions, -6 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/server/src/services/turn-games/turn-game-bot-runner.service.ts(+28 -6)📄 Description
Linked issue
Closes #3427
Why this change
When the connected model is a reasoning model that emits its chain-of-thought inline in
content(a leading<think>/<thinking>block) instead of a provider-native thinking channel, turn-game narration saves that reasoning verbatim as the character's chat message. With the previous 100/120-token narration budgets the reasoning routinely ate the whole budget, so what landed in chat was a truncated meta monologue ("The user wants me to say one short, natural line as … Let me think of something she would say -") instead of a spoken line. This affects all four turn games (UNO, chess, poker, 8-ball): both the bot's post-move table talk and the dealer/announcer lines.The main generation pipeline already strips these blocks (
extractLeadingThinkingBlocksingenerate.routes.ts/game.routes.ts); the turn-game bot runner predates none of that but never adopted it.What changed
All changes are in
packages/server/src/services/turn-games/turn-game-bot-runner.service.ts(plus a CHANGELOG entry):stripInlineThinking()helper applied to both narration paths (narrateOutcome,narrateAnnouncements): strips leading inline thinking blocks using the same shared extractor as the generation pipeline, and — the case a plain strip cannot recover — returns an empty line when an unclosed opening tag remains at the front (maxTokens ran out mid-thought, so everything present is reasoning). Both call sites already fall back to the factual event summary on an empty line, so the worst case is now a dry-but-correct line instead of leaked chain-of-thought.maxTokensraised from 100/120 to 300 so reasoning models have headroom to finish thinking and still produce the spoken line.res.toolCalls, so inline reasoning there was never persisted.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Done so far:
pnpm check(typecheck + lint + build) passes locally.stripInlineThinking(11 cases): plain lines pass through; closed<think>/<thinking>/[think]blocks stripped (case-insensitive, multiple consecutive blocks); the exact truncated-unclosed-block shape from the bug report returns empty (fallback path); tags mentioned mid-line are not treated as thinking.Still to verify manually before promoting:
Docs and release impact
CHANGELOG entry added under [Unreleased] → Fixed. No version bump; no other docs reference turn-game narration internals.
UI evidence (if applicable)
Server-side narration fix — the user-visible effect is the absence of leaked reasoning in chat. The linked issue quotes the leaked message this fixes.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.