fix(mcp-runtime): use truncateUtf16Safe for MCP metadata text truncation#102500
Conversation
Replace naive .slice(0, N) with truncateUtf16Safe() to prevent surrogate pair splitting in MCP tool metadata descriptions shown to users through the bundle MCP runtime catalog. Co-Authored-By: Claude <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 3:42 AM ET / 07:42 UTC. Summary PR surface: Source +1, Tests +44. Total +45 across 2 files. Reproducibility: yes. source-reproducible: current main raw-slices MCP metadata text at 1200 UTF-16 code units, so an emoji crossing that cutoff can leave a dangling surrogate. I did not run the test in this read-only review. Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Merge the narrow sanitizer helper replacement once redacted real OpenClaw MCP runtime proof or a maintainer proof override accompanies the focused regression coverage. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main raw-slices MCP metadata text at 1200 UTF-16 code units, so an emoji crossing that cutoff can leave a dangling surrogate. I did not run the test in this read-only review. Is this the best way to solve the issue? Yes. Reusing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3b418bdef6e5. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1, Tests +44. Total +45 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
|
Land-ready maintainer verification at exact head
No docs, config, protocol, or changelog surface changes. |
|
Merged via squash.
|
…ion (openclaw#102500) * fix(mcp-runtime): use truncateUtf16Safe for MCP metadata text truncation Replace naive .slice(0, N) with truncateUtf16Safe() to prevent surrogate pair splitting in MCP tool metadata descriptions shown to users through the bundle MCP runtime catalog. Co-Authored-By: Claude <[email protected]> * test(mcp-runtime): cover UTF-16 metadata boundary * style(mcp-runtime): keep imports grouped --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
The bundle MCP runtime truncates tool metadata descriptions using naive
.slice(0, BUNDLE_MCP_METADATA_TEXT_LIMIT). This can split surrogate pairs mid-character in MCP tool descriptions shown to users.Why This Change Was Made
Replace with
truncateUtf16Safe()which preserves surrogate pair boundaries. Same pattern as #102464 and #102467 (both merged).Evidence
Files Changed
src/agents/agent-bundle-mcp-runtime.ts.slice(0,N)→truncateUtf16Safe()🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]