mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8652] [MERGED] fix(generate): a streamed reply is no longer saved shorter than it was shown #8724
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#8724
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/8652
Author: @SpicyMarinara
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/streamed-reply-truncation-8643📝 Commits (1)
5d063e3fix(generate): a streamed reply is no longer saved shorter than it was shown (#8643)📊 Changes
8 files changed (+165 additions, -13 deletions)
View changed files
📝
packages/client/src/hooks/use-generate.ts(+8 -0)📝
packages/client/src/localization/locales/en.json(+1 -0)📝
packages/server/src/routes/generate.routes.ts(+2 -0)📝
packages/server/src/routes/generate/reply-text-cleanup.ts(+7 -3)📝
packages/server/src/services/agents/agent-executor.ts(+17 -4)📝
packages/server/src/services/generation/generation-text-utils.ts(+6 -2)📝
scripts/regressions/agent-runtime.regression.ts(+53 -0)📝
scripts/regressions/generate-reply-text-cleanup.regression.ts(+71 -4)📄 Description
Linked issue
Closes #8643
Why this change
trimIncompleteModelOutput. Both turned out to be real server paths that save a fully streamed reply as an exact prefix of what was shown. Each is reproduced in a regression. The issue doesn't say which settings were on, so this PR fixes both.What changed
1. A rewrite agent that ran out of tokens no longer overwrites the reply.
text_rewriteagents return the whole reply as JSONeditedText, with a 4096-token default limit.length.repairJsonTextthen closed the unfinished string, the result counted as a success, and the generate route saved it withupdateMessageContent. The client swapped the streamed text for it: an exact prefix.resolveStructuredAgentResult(inagent-executor.ts) now fails atext_rewriteresult whose call ended unfinished. This covers the single call, the JSON retry and both tool-loop endings. A failed rewrite is never applied, and with "hold for rewrite" on, the route already sends back the original.2. "Trim incomplete sentences" no longer cuts finished replies.
*She smiles softly.*), HTML closing tags (<i>Finally home.</i>) and CJK closing brackets (「また明日ね。」). A finished reply ending that way lost its whole last paragraph.reply_trimmedevent and the client shows an info toast that names the setting (new keychat.reply.trimmedIncompleteEnding, English only). Autonomous replies show no toast.Regressions.
agent-runtimegains cut-off rewrites for Prose Guardian and a custom rewrite agent, with and without tools.generate-reply-text-cleanupgains finished endings with emphasis, tags and CJK brackets, a truly cut-off line, and thereply_trimmedwiring. Each fails on the old code and passes now.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
What the agent ran locally:
node ./scripts/pnpm-runner.mjs checkandlocalization:checkpass, after rebasing on staging.agent-runtime,generate-reply-text-cleanup,roleplay-streaming,reply-checkup,agent-retry-batching,manual-agent-retry-resolutionandmerged-rewrite-lorebooks.To verify by hand:
*She smiles.*stays whole, and a reply really cut off by a low max-token limit is trimmed and shows the new toast.Not changed (follow-ups):
replyUnfinisheddoesn't know GLM's ownnetwork_error/sensitivefinish reasons.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)No docs change: both are bug fixes behind existing settings.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.