[PR #3597] [MERGED] Fix Unicode surrogate splitting in recalled memory #6010

Closed
opened 2026-10-23 04:06:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3597
Author: @SpicyMarinara
Created: 7/14/2026
Status: ✅ Merged
Merged: 7/14/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/3596-unicode-memory-truncation


📝 Commits (1)

  • b02be25 fix(memory): preserve unicode during recall truncation

📊 Changes

3 files changed (+40 additions, -3 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/services/generation/memory-recall-pack.ts (+20 -3)
📝 scripts/regressions/prompt.regression.ts (+19 -0)

📄 Description

Closes #3596

Why

Long Conversation memories containing supplementary Unicode characters (including emoji and Lydian text) could be truncated between their UTF-16 surrogate halves. The isolated surrogate was then serialized into the provider request, which strict JSON parsers such as llama.cpp reject.

What changed

  • Make both recalled-memory truncation cuts retreat past split surrogate-pair boundaries while preserving the existing code-unit budget.
  • Cover both the retained head and retained tail boundaries with supplementary-Unicode prompt regressions.
  • Document the fix in the v2.2.2 changelog.

Validation

  • Run pnpm regression:prompt
  • Run pnpm check
  • Manually verify a long Conversation memory containing emoji and Lydian text completes through llama.cpp without a JSON parse error.

Risk

This touches prompt assembly. Automated coverage proves that truncation no longer creates isolated UTF-16 surrogates at either boundary and that the broader prompt regression suite remains green. Live llama.cpp verification remains a manual check because no configured local provider is available in this workspace.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/3597 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/14/2026 **Status:** ✅ Merged **Merged:** 7/14/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/3596-unicode-memory-truncation` --- ### 📝 Commits (1) - [`b02be25`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b02be259880d78abc979c63522a753dfe68b983d) fix(memory): preserve unicode during recall truncation ### 📊 Changes **3 files changed** (+40 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/services/generation/memory-recall-pack.ts` (+20 -3) 📝 `scripts/regressions/prompt.regression.ts` (+19 -0) </details> ### 📄 Description Closes #3596 ## Why Long Conversation memories containing supplementary Unicode characters (including emoji and Lydian text) could be truncated between their UTF-16 surrogate halves. The isolated surrogate was then serialized into the provider request, which strict JSON parsers such as llama.cpp reject. ## What changed - Make both recalled-memory truncation cuts retreat past split surrogate-pair boundaries while preserving the existing code-unit budget. - Cover both the retained head and retained tail boundaries with supplementary-Unicode prompt regressions. - Document the fix in the v2.2.2 changelog. ## Validation - [ ] Run `pnpm regression:prompt` - [ ] Run `pnpm check` - [ ] Manually verify a long Conversation memory containing emoji and Lydian text completes through llama.cpp without a JSON parse error. ## Risk This touches prompt assembly. Automated coverage proves that truncation no longer creates isolated UTF-16 surrogates at either boundary and that the broader prompt regression suite remains green. Live llama.cpp verification remains a manual check because no configured local provider is available in this workspace. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:06:10 +07:00
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#6010
No description provided.