You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "shaynhornik (via GitHub)" <gi...@apache.org> on 2026/09/01 06:39:23 UTC
[PR] fix(runtime): keep MCP text clipping from splitting surrogate pairs [maka]
shaynhornik opened a new pull request, #4438:
URL: https://github.com/apache/maka/pull/4438
## Summary
`clipModelText` bounds MCP tool-result text with a raw `.slice()` at a UTF-16
index, so a clip boundary inside an astral character (any emoji) left an
unpaired high surrogate in the text block handed to the model — ill-formed
UTF-16 that any UTF-8 round trip (provider request body, durable storage)
mangles into U+FFFD. The fix drops the dangling high surrogate before
appending the truncation marker, the same boundary handling
`local-memory.ts:311` already uses. Both call sites (`appendText` and the
resource-text path in `summarizeNonVisualBlock`) go through the shared helper,
so one change covers both.
Fixes #4435
## Verification
- Added a regression test in `packages/runtime/src/__tests__/mcp-tools.test.ts`
that clips `'🦊'.repeat(120_000)` through the public
`buildMcpTools` → `toModelOutput` path and asserts the result contains no
unpaired surrogate, keeps the truncation marker, and stays within the
200,000-char budget. It fails without the fix (7 pass / 1 fail) and passes
with it (8 pass / 0 fail) via `node --test packages/runtime/dist/__tests__/mcp-tools.test.js`.
- `npm run lint`, `npm run format:check`, `npm run typecheck`, and
`npm run build` all pass locally (Node 22.21.0, Linux x64).
- Not run: the graphical/E2E suites — this change is runtime-only text
handling with no UI surface.
## AI use
Select exactly one:
- [ ] No generative tool made a substantive contribution
- [x] Generative tooling made a substantive contribution
Tool(s) and scope: Claude Code (Fable 5) found the bug and wrote the fix and
regression test at my direction; I reviewed the change, ran the verification,
and own the submission. The affected commit carries a `Generated-by` trailer.
## Checklist
- [x] Tests cover the change and fail without it
- [x] Lint, format, typecheck and the affected suites pass locally
Does this PR entail a change in behavior?
- [x] Yes — described under Summary above
- [ ] No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): keep MCP text clipping from splitting surrogate pairs [maka]
Posted by "shaynhornik (via GitHub)" <gi...@apache.org>.
shaynhornik commented on PR #4438:
URL: https://github.com/apache/maka/pull/4438#issuecomment-5513925335
Rebased onto `main` (a00d1f3); core, mcp and runtime suites still green locally after the rebase.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): keep MCP text clipping from splitting surrogate pairs [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #4438:
URL: https://github.com/apache/maka/pull/4438
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): keep MCP text clipping from splitting surrogate pairs [maka]
Posted by "shaynhornik (via GitHub)" <gi...@apache.org>.
shaynhornik commented on PR #4438:
URL: https://github.com/apache/maka/pull/4438#issuecomment-5497907333
Took the helper: truncateUtf16Safe is now exported from text-sanitize with direct unit tests, and both this call site and local-memory.ts point at it (the existing local-memory boundary test still passes unchanged). I left sep-2243, telegram-bridge, and thread-search alone since their budgets are code-point/chunking shaped rather than a straight code-unit cap — happy to do those in a follow-up if you'd like.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): keep MCP text clipping from splitting surrogate pairs [maka]
Posted by "shaynhornik (via GitHub)" <gi...@apache.org>.
shaynhornik commented on PR #4438:
URL: https://github.com/apache/maka/pull/4438#issuecomment-5501711231
Went back over the other three sites after your list. The sep-2243 warning ellipsis and the Telegram prefix are both plain code-unit caps, so my "code-point/chunking shaped" was wrong for those two. Both now call `truncateUtf16Safe` (e4e2979), which drops the Telegram-local prefix walk and its direct test (the same cases live in `text-sanitize.test.ts`). `thread-search`'s `capCodePoints` stays: its budget is code points rather than code units, so it's a different contract, not another copy. That leaves two implementations for two different units. mcp 179/179, runtime and core suites green, biome and the ASF header check clean.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): keep MCP text clipping from splitting surrogate pairs [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #4438:
URL: https://github.com/apache/maka/pull/4438#issuecomment-5510996604
The `Test CI planner` failure is not yours: the run was approved today against a merge ref computed on 1 September, before #4523 changed `ci.yml`, and a rerun reuses that merge commit. A rebase onto `main` will trigger a fresh run; nothing else needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org