[GH-ISSUE #8643] [Bug]: Fully streamed Roleplay response flashes and becomes a shorter unchanged prefix after completion #8439

Closed
opened 2026-11-07 16:42:57 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @psych0genesis on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8643

Originally assigned to: @SpicyMarinara on GitHub.

Observed behavior

In Roleplay mode, a multi-paragraph assistant response was visibly displayed in full during streaming. Immediately when generation finished, the chat flashed/re-rendered and the displayed message abruptly became shorter, ending mid-sentence. The remaining text matched the original prefix exactly; no paraphrase or rewritten wording was observed in the retained segment. No explicit error appeared.

The user did not reload the page, so it is unknown whether the truncated version was actually persisted or the issue was only a client presentation/cache handoff.

A subsequent out-of-character request to redisplay the response caused a new response with essentially the same narrative continuing naturally beyond the prior cutoff. It contained at least one small wording/formatting difference. This was regeneration, not proof that the complete first response was stored or restored.

Expected behavior

The content already shown as a completed reply should not silently lose its ending when the stream is finalized or the saved message replaces the live buffer. If cleanup or a model length limit shortens a reply, surface what happened and preserve/recover original content where possible.

Diagnostic leads, not established root causes

  • Compare lengths and hashes of streaming text, final content_replace payload, message_saved data, and reloaded/persisted message. Do not require submitting private story text.
  • packages/client/src/hooks/use-generate.ts can replace the displayed stream via replaceGeneratedContentWithTypewriter; packages/client/src/lib/generation-stream-policy.ts reconciles authoritative shorter replacements by shortening visible text.
  • Check trimIncompleteModelOutput during server-side cleanup; user setting not checked for this occurrence.
  • Check if any post-generation text-rewriting agent modified the saved reply, though the surviving portion was unchanged.
  • Record finish reason and any output-limit flags; a displayed token count alone cannot establish length truncation.

Reproduction investigation

  1. Generate a multi-paragraph Roleplay response with streaming enabled.
  2. Observe full streamed text, then watch for flash and disappearance of its end during completion.
  3. Compare raw streamed vs post-cleanup vs saved text lengths. Check whether reload restores the full text.
  4. Compare with incomplete-ending trimming disabled and with post-generation rewrite agents disabled, if enabled.

Environment / uncertainty

Desktop Roleplay UI, GLM 5.3 Flash family model. Exact application build, setting states, reproducibility frequency, and the stage where content was lost are unverified.

Related but not duplicate issues: #4714 (formatting changes at stream completion), #2739 (abort persistence), #2737 (content replaced by rewrite). No stop/abort action was reported.

This report deliberately contains no identifying names, locations, machine paths, story excerpts or screenshots.

Originally created by @psych0genesis on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8643 Originally assigned to: @SpicyMarinara on GitHub. ## Observed behavior In Roleplay mode, a multi-paragraph assistant response was visibly displayed in full during streaming. Immediately when generation finished, the chat flashed/re-rendered and the displayed message abruptly became shorter, ending mid-sentence. The **remaining text matched the original prefix exactly**; no paraphrase or rewritten wording was observed in the retained segment. No explicit error appeared. The user did **not** reload the page, so it is **unknown** whether the truncated version was actually persisted or the issue was only a client presentation/cache handoff. A subsequent out-of-character request to redisplay the response caused a **new** response with essentially the same narrative continuing naturally beyond the prior cutoff. It contained at least one small wording/formatting difference. This was regeneration, **not** proof that the complete first response was stored or restored. ## Expected behavior The content already shown as a completed reply should not silently lose its ending when the stream is finalized or the saved message replaces the live buffer. If cleanup or a model length limit shortens a reply, surface what happened and preserve/recover original content where possible. ## Diagnostic leads, not established root causes - Compare lengths and hashes of streaming text, final `content_replace` payload, `message_saved` data, and reloaded/persisted message. Do not require submitting private story text. - `packages/client/src/hooks/use-generate.ts` can replace the displayed stream via `replaceGeneratedContentWithTypewriter`; `packages/client/src/lib/generation-stream-policy.ts` reconciles authoritative shorter replacements by shortening visible text. - Check `trimIncompleteModelOutput` during server-side cleanup; user setting **not checked** for this occurrence. - Check if any post-generation text-rewriting agent modified the saved reply, though the surviving portion was unchanged. - Record finish reason and any output-limit flags; a displayed token count alone cannot establish length truncation. ## Reproduction investigation 1. Generate a multi-paragraph Roleplay response with streaming enabled. 2. Observe full streamed text, then watch for flash and disappearance of its end during completion. 3. Compare raw streamed vs post-cleanup vs saved text lengths. Check whether reload restores the full text. 4. Compare with incomplete-ending trimming disabled and with post-generation rewrite agents disabled, if enabled. ## Environment / uncertainty Desktop Roleplay UI, GLM 5.3 Flash family model. Exact application build, setting states, reproducibility frequency, and the stage where content was lost are unverified. Related but **not duplicate** issues: #4714 (formatting changes at stream completion), #2739 (abort persistence), #2737 (content replaced by rewrite). No stop/abort action was reported. This report deliberately contains no identifying names, locations, machine paths, story excerpts or screenshots.
bsakaguchi 2026-11-07 16:42:57 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Nov 1, 2026):

Thanks for the careful report. Both of your leads turned out to be real, and #8652 fixes each one:

  1. A rewrite agent that ran out of tokens. This covers Prose Guardian, Continuity, Immersive HTML and custom rewrite agents. On a model that always reasons, like GLM 5.3, a long reply can use up the agent's output budget. The rewrite then stops mid-sentence and used to be saved over your reply as an exact prefix. A rewrite that doesn't finish is now never applied.
  2. "Trim incomplete sentences from the response". When this is on, a finished reply ending in something like *She smiles softly.* lost its last paragraph. That no longer happens, and when the trim really does cut a reply, a toast now tells you.

To confirm which one you hit: did you have a rewrite agent turned on (and was "hold for rewrite" off), or the trim setting? If it happens again after #8652 reaches staging, please reopen this issue.

🤖 Generated with Claude Code

<!-- gh-comment-id:6561789306 --> @SpicyMarinara commented on GitHub (Nov 1, 2026): Thanks for the careful report. Both of your leads turned out to be real, and #8652 fixes each one: 1. **A rewrite agent that ran out of tokens.** This covers Prose Guardian, Continuity, Immersive HTML and custom rewrite agents. On a model that always reasons, like GLM 5.3, a long reply can use up the agent's output budget. The rewrite then stops mid-sentence and used to be saved over your reply as an exact prefix. A rewrite that doesn't finish is now never applied. 2. **"Trim incomplete sentences from the response".** When this is on, a finished reply ending in something like `*She smiles softly.*` lost its last paragraph. That no longer happens, and when the trim really does cut a reply, a toast now tells you. To confirm which one you hit: did you have a rewrite agent turned on (and was "hold for rewrite" off), or the trim setting? If it happens again after #8652 reaches staging, please reopen this issue. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@SpicyMarinara commented on GitHub (Nov 1, 2026):

Fixed in #8652, merged into staging (both paths described above). Please reopen if it still happens once you're on staging.

<!-- gh-comment-id:6562766156 --> @SpicyMarinara commented on GitHub (Nov 1, 2026): Fixed in #8652, merged into `staging` (both paths described above). Please reopen if it still happens once you're on staging.
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#8439
No description provided.