Skip to content

fix(gateway): keep an astral MCP event description whole at the catalog cap - #181741

Merged
obviyus merged 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/mcp-events-astral-description
Oct 24, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/mcp-events-astral-description

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

mcp.events.list could split an astral character at the existing 4,096 UTF-16-unit description cap and return a lone surrogate. Reuse truncateUtf16Safe, following #176207 and #176230, without changing the cap or MCP catalog contract.

Evidence

Built main and candidate in isolated Node 24.22.1 Docker. Configured the bundled MCP Events plugin normally against an external loopback Streamable HTTP fixture implementing server/discover and events/list. Called the running Gateway through shipped gateway call mcp.events.list --json.

  • Main, twice: 4,096 units, not well formed; actual RPC description ends aaaaaa\ud83d.
  • Candidate, twice: 4,095 units, well formed; actual RPC description ends aaaaaaa.
  • Both short-description/cursor controls: short 😀 description, 20 units, well formed; nextCursor: page2 preserved.

Simplification keeps the existing truncation owner: production +2/-1 lines; tests +15/-0 against main. The focused regression protects the split-surrogate boundary.

Thanks to @wangmiao0668000666 for reporting and fixing this.

Two-way door: a revert restores the previous read-only projection. No persisted state or config changes. Blast radius is descriptions in MCP event discovery RPC responses.

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Oct 23, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves complete UTF-16 surrogate pairs when truncating MCP event descriptions to the existing 4096-unit limit.

Example: calendar.changed has a description containing 4095 ASCII a characters followed by 😀 and tail.

  • Before: The catalog returns 4095 a characters followed by a lone U+D83D surrogate.
  • After: The catalog returns 4095 a characters, omitting the character that cannot fit whole.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, useful repair with supplied shipped-RPC evidence, a meaningful regression, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied results exercise the catalog projection through a running Gateway's shipped mcp.events.list RPC with real loopback Streamable HTTP transport on Node 24.22.1: the boundary description changes from 4096 units with a lone surrogate to 4095 well-formed units, while short descriptions and pagination remain intact; the merged head preserves this repair.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A valid MCP event description can acquire a dangling surrogate in the Gateway catalog response.
Reason: The repair preserves valid character boundaries using an existing utility without adding configuration, public API, or persistence.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current-main Unicode truncation bug with a minimal change and meaningful regression coverage; no actionable defects were found.

Priority: P2
Reviewed head: 4643d3dc5b8cad477284dd2c7b46a41452e2275f

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The added regression's base-fail/head-pass test execution is not supplied, although the shipped Gateway results cover the failing boundary and preserved controls.
Agent review details

How this fits together

The Gateway retrieves event definitions from configured MCP servers and projects a bounded catalog for the Automation editor and MCP Events discovery tool.

flowchart LR
  A[Catalog client] --> B[Gateway RPC]
  B --> C[Configured MCP server]
  C --> D[Catalog projection]
  D --> E[UTF16 truncation helper]
  E --> F[Bounded catalog response]
Loading

Technical review

Best possible solution:

Retain the canonical-helper substitution and focused catalog-response regression.

Do we have a high-confidence way to reproduce the issue?

Current-main source deterministically splits the reported surrogate pair, matching the supplied Gateway red/green results; this read-only review did not execute target code.

Is this the best way to solve the issue?

This is the smallest complete fix: reuse the existing surrogate-safe truncation owner while preserving the catalog limit and response shape.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2e267509979f.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Verified introduced patch: The pinned introduction diff adds the existing truncation-helper import, substitutes it for raw slice, and adds one handler-response regression. (src/gateway/server-methods/mcp-events.ts:46, 4643d3dc5b8c)
  • Current main still needs the repair: Fetched main retains description.slice(0, 4096), which splits the reported surrogate pair. (src/gateway/server-methods/mcp-events.ts:45, 2e267509979f)
  • Canonical helper contract: truncateUtf16Safe preserves descriptions within the limit and retreats one unit when truncation would split a surrogate pair; its package entry point already exists. (packages/normalization-core/src/utf16-slice.ts:58, 4643d3dc5b8c)
  • Supplied shipped-RPC evidence: The PR body records isolated Node 24.22.1 Docker runs using a configured MCP Events plugin, real loopback Streamable HTTP transport, and gateway call mcp.events.list --json: baseline returns a lone surrogate; candidate returns a well-formed 4095-unit description, with short-description and cursor controls preserved. (4643d3dc5b8c)
  • Feature provenance and ownership: Scoped path and symbol history identify the original bounded catalog in feat: trigger automations from MCP events #165399 and subsequent canonical-helper and response-owner refactors by Peter Steinberger; the repair preserves their ownership and bounded-response intent. (src/gateway/server-methods/mcp-events.ts:45, e210870acfe2)
  • Re-review and merge reconciliation: The previous review recorded no findings; the latest merge retains the same truncation repair and incorporates main's requester-projection and response-owner refactors. Collaborator obviyus requested this re-review. (src/gateway/server-methods/mcp-events.ts:46, 4643d3dc5b8c)

Likely related people:

  • Peter Steinberger: Raw commit f18d529 adds src/gateway/server-methods/mcp-events.ts:2 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f18d529467b0; files: src/gateway/server-methods/mcp-events.ts)
  • RoboClaw: Raw commit e210870 adds src/gateway/server-methods/mcp-events.ts:19 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: e210870acfe2; files: src/gateway/server-methods/mcp-events.ts)

PR surface

Source +1, Tests +15. Total +16 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 15 0 +15
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 17 1 +16

Review metrics

Metric Value Why it matters
Production versus test LOC Production +2/-1; tests +15/-0 One helper substitution fixes the boundary, and one regression protects the observable catalog response without new scaffolding.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The defect corrupts description metadata when a surrogate pair crosses the catalog limit, with limited blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-23T16:17:56.818Z sha 5b6f05b :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-24T01:59:41.017Z sha 5b6f05b :: needs maintainer review before merge. :: none

Reviewed October 24, 2026, 11:13 AM ET / 15:13 UTC (Revision 3).

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 24, 2026
# Conflicts:
#	src/gateway/server-methods/mcp-events.ts
@obviyus

obviyus commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@obviyus
obviyus merged commit 3fe9908 into openclaw:main Oct 24, 2026
125 checks passed
@obviyus

obviyus commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

Landed in 3fe9908. Thanks @wangmiao0668000666. mcp.events.list descriptions no longer split emoji.

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus for reviewing and merging this — keeping the astral MCP event description whole at the catalog cap helps avoid truncating useful context for the gateway path. Appreciate the quick turnaround!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…og cap (openclaw#181741)

fix(mcp): don't split an emoji in mcp.events.list descriptions

mcp.events.list cut event descriptions at 4096 UTF-16 units, which could split an emoji and return a lone surrogate (invalid Unicode) to clients. The cut now uses the existing truncateUtf16Safe owner and stops at a whole character; paging is unchanged.

Evidence: built Gateway, mcp.events.list over the public RPC. On main a description ending in an emoji came back as 4096 units with a lone U+D83D (twice); with this change it is 4095 units of valid text (twice). Short descriptions and the next-page cursor are unchanged.

Thanks @wangmiao0668000666.

Co-authored-by: Ayaan Zaidi <[email protected]>
@wangmiao0668000666
wangmiao0668000666 deleted the fix/mcp-events-astral-description branch October 28, 2026 07:38
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…og cap (#181741)

fix(mcp): don't split an emoji in mcp.events.list descriptions

mcp.events.list cut event descriptions at 4096 UTF-16 units, which could split an emoji and return a lone surrogate (invalid Unicode) to clients. The cut now uses the existing truncateUtf16Safe owner and stops at a whole character; paging is unchanged.

Evidence: built Gateway, mcp.events.list over the public RPC. On main a description ending in an emoji came back as 4096 units with a lone U+D83D (twice); with this change it is 4095 units of valid text (twice). Short descriptions and the next-page cursor are unchanged.

Thanks @wangmiao0668000666.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 3fe9908)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit f9828683b0d4827c61333c594a847564e64150a9)
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…og cap (#181741) [baseline validation follow-up]

fix(mcp): don't split an emoji in mcp.events.list descriptions

mcp.events.list cut event descriptions at 4096 UTF-16 units, which could split an emoji and return a lone surrogate (invalid Unicode) to clients. The cut now uses the existing truncateUtf16Safe owner and stops at a whole character; paging is unchanged.

Evidence: built Gateway, mcp.events.list over the public RPC. On main a description ending in an emoji came back as 4096 units with a lone U+D83D (twice); with this change it is 4095 units of valid text (twice). Short descriptions and the next-page cursor are unchanged.

Thanks @wangmiao0668000666.

Co-authored-by: Ayaan Zaidi <[email protected]>

Complete the source-equivalent baseline adaptation and checked-in regressions; normalize with the checkout formatter.

(cherry picked from commit 3fe9908)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 8701eac4c6483cee63d95d9206d483643f975afd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants