mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
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#5715
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/2674
Author: @kolacheee
Created: 6/20/2026
Status: ✅ Merged
Merged: 6/21/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/anthropic-prefill-trailing-whitespace📝 Commits (2)
cdee7e8fix(prompt): trim trailing whitespace from assistant prefill before send (#2673)7501a09fix(anthropic): trim trailing whitespace from the final assistant turn at serialization (#2679)📊 Changes
3 files changed (+38 additions, -5 deletions)
View changed files
📝
packages/server/src/routes/generate/dry-run-route.ts(+3 -1)📝
packages/server/src/routes/generate/generate-route-utils.ts(+5 -1)📝
packages/server/src/services/llm/providers/anthropic.provider.ts(+30 -3)📄 Description
Linked issues
Closes #2673
Closes #2679
Why this change
Reports of "presets that work in SillyTavern get blocked/refused in Marinara" trace, in part, to a literal API error being surfaced as a refusal. Anthropic rejects a final assistant turn whose content ends in whitespace with HTTP 400 (
final assistant content must not end with trailing whitespace). Trailing newlines/spaces on the final assistant turn are extremely common, so a large fraction of Anthropic generations fail — and the failure looks like a content block to the user.This PR fixes that in two layers:
\nor a space (<thinking>\n,Sure,) are extremely common.role:assistantsection, or — undermarkdown/nonewrap — the last chat-history assistant message. These still reached Anthropic untrimmed and produced the same 400.What changed
appendGenerationTailMessages(generate-route-utils.ts) now pushesassistantPrefill.trimEnd()as the trailing assistant message instead of the untrimmed value. The dry-run preview (dry-run-route.ts) is updated the same way so the preview matches what is actually sent.trimTrailingAssistantWhitespace()inanthropic.provider.tsstrips the trailing edge of the last assistant message at the point of serialization, applied in bothchat()(aftermergeConsecutiveMessages) andchatComplete()(beforeformatAnthropicPayloadMessages). This centralizes the guard so every trailing-assistant surface — prefill, depth-injected assistant, merged assistant, history assistant — is covered in one place, generalizing the prefill fix.Only the trailing edge Anthropic rejects is stripped; leading whitespace and non-trailing turns are preserved, and user-facing prefill rendering is unchanged. Harmless for OpenAI / Google (they do not reject trailing whitespace).
Validation
Automated (done by the agent):
pnpm checkpassed locally — TypeScript + ESLint + build (exit0) — for both the prefill change and the serialization change.pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
On an Anthropic connection:
<thinking>\n) and send → should succeed (previously400'd). Confirm the displayed reply still begins with the intended prefill.role:assistantinjected section / lorebook entry whose content ends in a newline, and send → should succeed (previously400'd).wrapFormat=markdownornone, make the most recent chat-history message an assistant message ending in\n, and send → should succeed.Docs and release impact
No docs/version changes.
UI evidence (if applicable)
N/A — server-only change.
Summary by CodeRabbit
Release Notes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.