[GH-ISSUE #3596] [Issue]: UTF surrogate pairing error in conversation memory #1946

Closed
opened 2026-10-21 05:44:02 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @g-maxime on GitHub (Jul 14, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3596

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Random "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF" when trying to generate a conversation reply.

Expected behavior

The system should generate a conversation reply

Actual behavior

At some point of the conversation I get this error, when the system should reply (after a message or scheduled event) :
Custom OpenAI-compatible endpoint error 500: [json.exception.parse_error.101] parse error at line 1, column 18876: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF;

Steps to reproduce

  1. Start a long conversation, mixing Lydian alphabet spells and emoji in replis
  2. Continue the conversation until the issue happens

Environment

  • Marinara Engine version: v2.2.1
  • Install type: Source
  • OS + version: Fedora Linux 44 / Node.js v24.13.1
  • Browser or app shell: Browser

Logs, screenshots, or video

LLama.cpp side log about this error:
W srv operator(): got exception: {"error":{"code":500,"message":"[json.exception.parse_error.101] parse error at line 1, column 18876: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '\"<instructions>...\\n...[recalled memory truncated]...\\n\\ude48'","type":"server_error"}}

Additional context

Changing the length of the last message to generate a different truncation point allows to step over the issue, until next time.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @g-maxime on GitHub (Jul 14, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3596 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Random "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF" when trying to generate a conversation reply. ## Expected behavior The system should generate a conversation reply ## Actual behavior At some point of the conversation I get this error, when the system should reply (after a message or scheduled event) : `Custom OpenAI-compatible endpoint error 500: [json.exception.parse_error.101] parse error at line 1, column 18876: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF;` ## Steps to reproduce 1. Start a long conversation, mixing Lydian alphabet spells and emoji in replis 2. Continue the conversation until the issue happens ## Environment - Marinara Engine version: v2.2.1 - Install type: Source - OS + version: Fedora Linux 44 / Node.js v24.13.1 - Browser or app shell: Browser ## Logs, screenshots, or video LLama.cpp side log about this error: `W srv operator(): got exception: {"error":{"code":500,"message":"[json.exception.parse_error.101] parse error at line 1, column 18876: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '\"<instructions>...\\n...[recalled memory truncated]...\\n\\ude48'","type":"server_error"}}` ## Additional context Changing the length of the last message to generate a different truncation point allows to step over the issue, until next time. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:44:02 +07:00
  • closed this issue
  • added the
    in-pr
    bug
    labels
Author
Owner

@SpicyMarinara commented on GitHub (Jul 14, 2026):

Claimed by @SpicyMarinara. I traced the failure to recalled-memory truncation splitting UTF-16 surrogate pairs at its head or tail boundary, which can send an isolated surrogate to strict JSON parsers such as llama.cpp. I am implementing boundary-safe truncation with a focused prompt regression.

<!-- gh-comment-id:4968349560 --> @SpicyMarinara commented on GitHub (Jul 14, 2026): Claimed by @SpicyMarinara. I traced the failure to recalled-memory truncation splitting UTF-16 surrogate pairs at its head or tail boundary, which can send an isolated surrogate to strict JSON parsers such as llama.cpp. I am implementing boundary-safe truncation with a focused prompt regression.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 14, 2026):

Fixed by #3597 and merged into staging. Recalled-memory truncation now preserves UTF-16 surrogate pairs at both retained boundaries, with prompt regression coverage for supplementary Unicode.

<!-- gh-comment-id:4968411745 --> @SpicyMarinara commented on GitHub (Jul 14, 2026): Fixed by #3597 and merged into `staging`. Recalled-memory truncation now preserves UTF-16 surrogate pairs at both retained boundaries, with prompt regression coverage for supplementary Unicode.
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#1946
No description provided.