Skip to content

fix(streaming): keep fitting emoji and accents intact in prose replies - #166567

Merged
obviyus merged 3 commits into
openclaw:mainfrom
rudycelekli:campaign/openclaw-grapheme-20261007
Oct 7, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
rudycelekli:campaign/openclaw-grapheme-20261007

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #166562

What Problem This Solves

Fixes emoji and accented characters being divided between block-streamed prose replies when they cross the hard character cut.

User Impact

A character that fits the complete reply budget stays together, including family emoji, flags, skin-tone modifiers and combining accents. Oversized clusters retain bounded progress; transport limits remain enforced. This does not change fenced-code or whitespace splitting into a Unicode-aware feature.

Why This Change Was Made

The prose fallback cut was surrogate-safe but could separate the code points making up one displayed character. It now reuses the existing normalization-core grapheme boundary helper. During streaming it waits for enough lookahead to establish the trailing cluster boundary; a whole leading cluster that fills the real cap can still progress immediately. Parser-confirmed closing fences keep their existing cuts, and source-range ownership stays intact.

The regression coverage also exercises actual subscribeEmbeddedAgentSession → onBlockReply delivery, using the repository's synthetic direct OpenAI Responses events. It requires complete authored text, an intact family emoji and bounded outgoing chunks for three event schedules.

Evidence

Candidate: 0216d75b6508a9db7dcd08ade81dd8f80482bd2a. Source baseline: 8242407539b5d783b8fb8793f54d7092b4bbbd5a. Supported Node 24.x, pinned frozen pnpm 12.5.1, physical owned-fork installation.

  • Exact-head native before/after, changed checks and build, all successful at 0216d75b6508a9db7dcd08ade81dd8f80482bd2a. Original production with these tests has 7 intended failures / 105 passing tests; corrected production passes 112/112 across both suites. Original suite 53.83s (launcher wall 57.63s); candidate 42.42s (launcher wall 46.07s). Controls cover closing fences, tiny budgets, exact-cap and oversized clusters, source metadata and terminal drains.

  • pnpm check:changed --base 8242407539b5d783b8fb8793f54d7092b4bbbd5a passed (2,290.29s wall), including type checks, pinned formatting, lint, ratchets, dead-code and runtime import-cycle guards. pnpm build passed (381.86s wall). These are owned-fork results, not a claim that the upstream PR's draft-skipped CI ran.

  • Independent repository autoreview of the full semantic candidate is scoped-clean through P2. Earlier review/native failures were corrected while preserving existing assertions. The final commit applies only pinned oxfmt 0.68.0 formatting to the new subscription fixture. No full repository suite or live channel/Gateway end-to-end result is claimed.

  • Upstream CI is not fully green: check-test-types-core-2 fails with TS2353 at ui/src/components/terminal/terminal-panel-fonts.test.ts:56 (signal is not a declared boot parameter). CI checks test-merge d10dc2977fb46d4eca4fc070a1cb985b9d3d7aee into base dfb27239f2b6265dad3d2059926f9cc86c34f2f3. The failing test and session-boot owner have identical blobs in that base and test-merge, and this PR changes neither file. This is recorded as an inherited base-source failure; it has not been fixed or waived here. Other upstream CI results may still be pending.

Remaining behavior-proof gate

ClawSweeper found no introduced code/security defects but requires real Telegram Test Server delivery proof before merge. That live proof has not run and remains open. Credentialed execution requires maintainer-approved QA access; no account lease or live credentials were used here.

A maintainer test handoff pinned to this candidate provides the maintained mock-provider scenario, 1/17-code-point schedules, exact payloads, message-boundary acceptance checks, source identity and lease/process cleanup requirements. Its 14 offline fixture checks pass; those checks do not replace real Telegram delivery evidence. The PR is available for review while this merge gate remains unresolved.

The existing link-preservation proposal #151242 touches the same owner for a different cause and may require mechanical reconciliation. Current main's production owner was checked and matches the pinned baseline. No dependencies, configuration or release artifacts change.

AI-assisted investigation and implementation. Maintainer edits are enabled.

@clawsweeper

clawsweeper Bot commented Oct 7, 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 agents Agent runtime and tooling size: S labels Oct 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 8:43 AM ET / 12:43 UTC (Revision 4).

ClawSweeper review

What this changes

The PR keeps fitting emoji and combining accents together at hard length cuts in streamed prose replies and adds chunker and subscription-delivery regressions.

Merge readiness

✅ Ready for maintainer review

This remains a useful fix absent from current main and the latest release. No introduced correctness or security defect was found; the new exact-head Telegram delivery transcript satisfies the earlier proof request. The inherited CI failure remains a landing-gate matter.

Priority: P2
Reviewed head: 0216d75b6508a9db7dcd08ade81dd8f80482bd2a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, sound repair now has convincing before/after channel-delivery evidence and meaningful regression coverage.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Exact-head Test Server output exercises the changed shared chunker through built Gateways and the real Telegram plugin, showing intact family emoji and accents, exact delivered-text reconstruction, and bounded messages. This satisfies the prior rank-up request; the unrelated CLI smoke is supplemental. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Exact-head Test Server output exercises the changed shared chunker through built Gateways and the real Telegram plugin, showing intact family emoji and accents, exact delivered-text reconstruction, and bounded messages. This satisfies the prior rank-up request; the unrelated CLI smoke is supplemental. No stored-data contract changes.
Evidence reviewed 8 items Pinned introduced change: The merge-base-to-head diff confines production changes to the existing prose fallback owner: it reuses the normalization-core grapheme helper, waits for trailing-cluster lookahead, preserves closed-fence cuts, and retains bounded progress for oversized clusters.
Still necessary on current main: The fetched main chunker is identical to the pinned source baseline and still returns a surrogate-safe hard cut without checking grapheme boundaries.
Latest release remains affected: Inspection of v2026.9.8 also shows the surrogate-only prose fallback; the requested correction is not present in that release.
Findings None None.
Security None None.

How this fits together

The shared reply chunker turns incoming model text into bounded blocks before channel delivery. Its boundaries determine whether a displayed character stays together in outgoing messages.

flowchart TD
  A[Model text deltas] --> B[Agent session subscription]
  B --> C[Shared reply chunker]
  C --> D{Safe prose boundary}
  D -->|Needs lookahead| E[Buffered text]
  E --> C
  D -->|Ready or final drain| F[Bounded reply blocks]
  F --> G[Channel delivery]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +24, Tests +133. Total +157 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 25 1 +24
Tests 2 134 1 +133
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 159 2 +157

Review metrics

Metric Value Why it matters
Production versus test growth production +24 net lines; tests +133 net lines Production growth is justified by trailing-cluster lookahead and reuse of the existing grapheme owner, with regressions covering source and delivery invariants.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #166562
Summary: This PR is the focused candidate fix for the paired grapheme issue; link preservation concerns a separate boundary contract.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep grapheme boundary selection in the existing shared prose chunker while preserving transport budgets, source custody, and established Markdown splitting.

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

Yes. The supplied current-main Test Server transcript reproduces family-emoji and accent splits at the default 1,200-unit block cap; source inspection confirms the same fallback remains on fetched main.

Is this the best way to solve the issue?

Yes. The patch repairs the existing prose boundary owner using the established grapheme helper, with bounded oversized-cluster progress and direct channel-delivery evidence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5a138f131cf8.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Exact-head Test Server output exercises the changed shared chunker through built Gateways and the real Telegram plugin, showing intact family emoji and accents, exact delivered-text reconstruction, and bounded messages. This satisfies the prior rank-up request; the unrelated CLI smoke is supplemental. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Exact-head Test Server output exercises the changed shared chunker through built Gateways and the real Telegram plugin, showing intact family emoji and accents, exact delivered-text reconstruction, and bounded messages. This satisfies the prior rank-up request; the unrelated CLI smoke is supplemental. No stored-data contract changes.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs a demonstrated, bounded streamed-reply formatting defect without changing configuration or public APIs.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Exact-head Test Server output exercises the changed shared chunker through built Gateways and the real Telegram plugin, showing intact family emoji and accents, exact delivered-text reconstruction, and bounded messages. This satisfies the prior rank-up request; the unrelated CLI smoke is supplemental. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Exact-head Test Server output exercises the changed shared chunker through built Gateways and the real Telegram plugin, showing intact family emoji and accents, exact delivered-text reconstruction, and bounded messages. This satisfies the prior rank-up request; the unrelated CLI smoke is supplemental. No stored-data contract changes.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The change affects visible Telegram message boundaries; the supplied Test Server userbot transcript demonstrates that behavior.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head diff confines production changes to the existing prose fallback owner: it reuses the normalization-core grapheme helper, waits for trailing-cluster lookahead, preserves closed-fence cuts, and retains bounded progress for oversized clusters. (src/agents/embedded-agent-block-chunker.ts:692, 0216d75b6508)
  • Still necessary on current main: The fetched main chunker is identical to the pinned source baseline and still returns a surrogate-safe hard cut without checking grapheme boundaries. (src/agents/embedded-agent-block-chunker.ts, 5a138f131cf8)
  • Latest release remains affected: Inspection of v2026.9.8 also shows the surrogate-only prose fallback; the requested correction is not present in that release. (src/agents/embedded-agent-block-chunker.ts, fc23bc864e45)
  • Real Telegram delivery resolves prior proof request: The supplied comment fix(streaming): keep fitting emoji and accents intact in prose replies #166567 (comment) records built Gateways and the Telegram plugin delivering replies to a Convex-leased Test Server user on the exact candidate. Family-message lengths improve from 1200/10 to 1195/15; accent-message lengths improve from 1200/5 to 1199/6. UTF-16 boundary output shows intact candidate clusters, and concatenated delivered text exactly matches both fixtures with every message at most 1200 units. This supersedes the older PR-body statement that live proof remains outstanding. (0216d75b6508)
  • Regression coverage and existing contracts: The added owner cases cover family emoji, accents, flags, skin tones, source-range continuity, exact-cap progress, and oversized clusters. Subscription cases additionally exercise actual event processing and final drainage under three provider schedules. The supplied delivery comment reports seven intended baseline failures and 112 candidate passes in 31.77 seconds; these results were inspected as evidence, not rerun locally. (src/agents/embedded-agent-block-chunker.test.ts:25, 0216d75b6508)
  • Verified merge ownership and inherited CI failure: Raw test-merge parents are the pinned base followed by the exact PR head. Comparing that merge against its base shows no change to the terminal font test implicated by TS2353. The supplied CI evidence identifies that unrelated type failure as the aggregate gate failure; it is not an introduced chunker defect. (ui/src/components/terminal/terminal-panel-fonts.test.ts:56, d10dc2977fb4)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • giodl73-repo: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-07T11:08:36.590Z sha 0216d75 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-07T12:10:45.884Z sha 0216d75 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-07T12:23:52.617Z sha 0216d75 :: needs real behavior proof before merge. :: none

@rudycelekli
rudycelekli marked this pull request as ready for review October 7, 2026 12:03
@obviyus

obviyus commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Telegram Test Server block-delivery proof

Verified the unchanged head 0216d75b6508a9db7dcd08ade81dd8f80482bd2a against current-main baseline 4ed39a25f674ceecbe7bb066503941085c911b6e through built Gateways and the Telegram plugin—not a mocked delivery callback.

The Convex-leased TDLib QA user sent a DM to the leased Test Server bot and recorded the bot's actual delivered messages. Doctor passed; each lease was released. Bot/user/chat identifiers are omitted below.

The OpenAI-compatible mock emitted seven-UTF-16-unit SSE deltas, 5 ms apart:

  • Family: "x".repeat(1195) + "👨‍👩‍👧‍👦" + "done".
  • Accent: "x".repeat(1199) + "e\u0301" + "done".

Both refs used the default block chunker (minChars=800, maxChars=1200), blockStreamingDefault: "on", blockStreamingBreak: "text_end", and Telegram streaming: {mode: "partial", block: {enabled: true, coalesce: {minChars: 1, maxChars: 1200, idleMs: 0}}}. Explicit block mode suppresses the preview lane. Gateway state was isolated on Docker tmpfs.

Observed messages

IDs below are the observing user's server message IDs (TDLib messageId >> 20, historically called botApiMessageId in the recorder), not the bot account's DM receipt IDs.

Ref / fixture User DM ID Delivered reply IDs Reply lengths (UTF-16) Result
Main / family 67511 67512, 67513 1200, 10 Family split
Candidate / family 67508 67509, 67510 1195, 15 Family intact
Main / accent 67519 67520, 67521 1200, 5 Accent split
Candidate / accent 67516 67517, 67518 1199, 6 Accent intact

The exact family boundary on main was:

reply 67512 ends:   d83d dc68 200d d83d dc69
reply 67513 starts: 200d d83d dc67 200d d83d dc66 0064 006f 006e 0065

Candidate reply 67509 ends in ASCII 0078; reply 67510 contains the complete family cluster followed by done:

d83d dc68 200d d83d dc69 200d d83d dc67 200d d83d dc66 0064 006f 006e 0065

Main's accent boundary was 0065 | 0301 0064 006f 006e 0065; candidate reply 67518 contains 0065 0301 0064 006f 006e 0065 together.

For all four successful turns, concatenating the delivered texts exactly reproduced the fixture and every message was ≤1200 UTF-16 units. Each candidate grapheme occurred wholly within one message. Mock request counts were 2 for main/family and 3 for each other turn (including auxiliary requests). An excluded main/accent transport attempt reached no provider; after a fresh doctor and isolated-port retry, the recorded successful result is the one above.

The recording command for each case was the repository run-mock-sut-user-e2e.mjs --dm --timeout-ms 90000 --gateway-port <isolated-port> --mock-port <isolated-port> --text 'p166567 <ref> <case>: answer with the supplied boundary fixture only' --record <events.ndjson> --output <summary.json>, with E2E_TELEGRAM_PROVIDER_API=openai-completions, the config above, and E2E_MOCK_SERVER_PATH pointing to the fixture. A host-side adapter launched the built dist/entry.js in secretless Docker and copied only the per-lease bot credential into tmpfs; the trusted host runner owned TDLib, lease heartbeat/release, and recording.

Supporting checks

  • The two PR test files on current main: 7 expected grapheme regressions failed, 105 passed (29.47 s selected-suite wall time).
  • The same files on the exact candidate: 112 passed (31.77 s selected-suite wall time). Command: pnpm test src/agents/embedded-agent-block-chunker.test.ts src/agents/embedded-agent-subscribe.subscribe-embedded-agent-session.subscribeembeddedagentsession.test.ts --maxWorkers=1.
  • Candidate pnpm tsgo: passed. Both runtime builds passed.
  • Exact-candidate built CLI, one real gpt-5-mini turn, reasoning low, output budget 4096: returned GRAPHEME_LIVE_OK; one assistant turn, no tools/fallback, 2708 input / 69 output tokens. The temporary key file was deleted.

CI classification

The latest completed exact-head CI run has openclaw/ci-gate: failure because check-test-types-core-2 reports ui/src/components/terminal/terminal-panel-fonts.test.ts(56,5): TS2353 (signal is not in the terminal boot contract). The same exact case failed on another PR's run. This PR changes only the shared reply chunker and its two agent regression suites; it cannot reach that terminal UI test type.

Cancelled jobs: 0 in that completed run. Skipped conditional matrix placeholders are not cancelled selected jobs. No CI jobs were rerun, no commits were pushed, and the PR body was not changed. This comment supplies the outstanding real-delivery evidence for re-review of the same SHA.

@obviyus

obviyus commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 7, 2026
@obviyus

obviyus commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Maintainer override: the only failing job on exact head 0216d75 is check-test-types-core-2 (https://github.com/openclaw/openclaw/actions/runs/37618323658/job/112783122276), plus the aggregate openclaw/ci-gate. The failure is a TS2353 in terminal-panel-fonts.test.ts:56 (signal absent from the terminal boot contract), from #166180's fixture. It also failed on another PR's run (https://github.com/openclaw/openclaw/actions/runs/37618323851/job/112783107240), and main repaired the fixture in 1d10375, which this merge lands on top of. This PR changes only the block chunker and its agent tests, which can't affect terminal UI test types. The 3 cancelled jobs are automation (auto-response, dispatch, PR context). Exact-head ClawSweeper is ready. Telegram Test Server before/after proof is in #166567 (comment).

@obviyus
obviyus merged commit 627d16b into openclaw:main Oct 7, 2026
220 of 226 checks passed
@obviyus

obviyus commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Landed in 627d16b. Thanks @rudycelekli! Verified on the Telegram Test Server: main split a family emoji and a combining accent across two messages at the 1,200-character cut; with this both stay whole, the text is complete, and every message stays within the limit.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
openclaw#166567)

Keep a grapheme that fits within the reply budget (family or flag emoji, skin-tone sequences, combining accents) whole when block-streamed prose crosses the hard chunk limit, instead of splitting it across replies. Chunks stay within the limit and the concatenated text is unchanged.

Fixes openclaw#166562.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

[Bug]: block-streamed prose splits fitting emoji and accented characters

2 participants