Skip to content

fix(voice-call): keep realtime context truncation UTF-16 safe#101304

Merged
steipete merged 2 commits into
openclaw:mainfrom
Alix-007:alix/utf16-voice-realtime-context
Jul 7, 2026
Merged

fix(voice-call): keep realtime context truncation UTF-16 safe#101304
steipete merged 2 commits into
openclaw:mainfrom
Alix-007:alix/utf16-voice-realtime-context

Conversation

@Alix-007

@Alix-007 Alix-007 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where realtime voice sessions could receive malformed injected agent context when the configured character cap landed between the UTF-16 code units of an emoji.

Why This Change Was Made

The existing voice-context limiter now uses OpenClaw's shared UTF-16-safe truncation helper while preserving the existing character budget and [truncated] marker. The focused regression drives the public instruction builder at the exact split-surrogate boundary and asserts the complete result.

User Impact

Realtime voice prompts remain valid Unicode at emoji boundaries instead of containing a dangling surrogate. Context limits and behavior outside truncation are unchanged.

Evidence

  • Blacksmith Testbox through Crabbox tbx_01kwxyz3apwmff73p7mhnzna80: corepack pnpm test extensions/voice-call/src/realtime-agent-context.test.ts — 1 file, 2 tests passed.
  • Same Testbox: corepack pnpm check:changed — passed.
  • Exact-head CI for c1bb06a35e24a89ed49004f917a2118c4479f8e2: https://github.com/openclaw/openclaw/actions/runs/28857280475 — passed.
  • Codex autoreview: production branch diff clean at 0.99 confidence; maintainer test cleanup clean at 0.98 confidence.
  • Live provider credentials were not needed because the defect and fix are entirely within deterministic prompt formatting.

AI-assisted; maintainer-reviewed and tested.

@openclaw-barnacle openclaw-barnacle Bot added channel: voice-call Channel integration: voice-call size: XS labels Jul 7, 2026
@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 12:50 AM ET / 04:50 UTC.

Summary
The branch replaces voice-call realtime agent-context raw string slicing with the existing UTF-16-safe truncation helper and adds a regression test for a surrogate-pair boundary.

PR surface: Source +1, Tests +25. Total +26 across 2 files.

Reproducibility: yes. Source inspection of current main shows raw slice at the truncation boundary can split a surrogate pair, and the added test constructs an agent id boundary that exercises the failure path; I did not run tests in this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Next step before merge

  • No ClawSweeper repair candidate is needed because the PR already contains the focused code change and regression test.

Security
Cleared: The diff only switches to an existing truncation helper and adds a focused test; it does not change dependencies, workflows, secrets, auth, network, or execution paths.

Review details

Best possible solution:

Land this narrow helper substitution and regression test if CI remains green; keep broader UTF-16 hardening as separate site-specific fixes rather than expanding this branch.

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

Yes. Source inspection of current main shows raw slice at the truncation boundary can split a surrogate pair, and the added test constructs an agent id boundary that exercises the failure path; I did not run tests in this read-only review.

Is this the best way to solve the issue?

Yes. Updating the existing limitText helper to use the shared UTF-16-safe truncation facade is the narrowest maintainable fix because both final agent capsules and workspace context snippets already flow through that helper.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c5d42593be6d.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied terminal output from the current head showing the affected runtime path returns hasLoneSurrogate:false, plus the focused Vitest command/output for the regression test.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes copied terminal output from the current head showing the affected runtime path returns hasLoneSurrogate:false, plus the focused Vitest command/output for the regression test.

Label justifications:

  • P3: The PR fixes a low-blast-radius voice-call prompt-formatting edge case without changing config, auth, migrations, provider routing, or delivery semantics.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes copied terminal output from the current head showing the affected runtime path returns hasLoneSurrogate:false, plus the focused Vitest command/output for the regression test.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied terminal output from the current head showing the affected runtime path returns hasLoneSurrogate:false, plus the focused Vitest command/output for the regression test.
Evidence reviewed

PR surface:

Source +1, Tests +25. Total +26 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 25 0 +25
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 27 1 +26

What I checked:

Likely related people:

  • Solvely-Colin: The realtime agent-context module and its limitText helper appear to date to the merge for fix ios qr scanner lifecycle #101235, authored by @Solvely-Colin. (role: introduced behavior; confidence: high; commits: 632efa2d7343; files: extensions/voice-call/src/realtime-agent-context.ts, extensions/voice-call/src/runtime.ts)
  • vincentkoc: @vincentkoc authored the merged UTF-16 bounded-output hardening at fix(text): keep bounded outputs UTF-16 safe #101355, which updated adjacent voice-call truncation sites with the same helper pattern. (role: recent adjacent contributor; confidence: medium; commits: 84e5327720b4; files: extensions/voice-call/src/media-stream.ts, extensions/voice-call/src/webhook.ts, src/talk/consult-question.ts)
  • Alix-007: The current PR author also appears as a co-author on the merged sibling UTF-16 hardening commit for fix(text): keep bounded outputs UTF-16 safe #101355, so they have relevant recent context beyond this proposal. (role: recent adjacent contributor; confidence: medium; commits: 84e5327720b4; files: extensions/voice-call/src/media-stream.ts, extensions/voice-call/src/webhook.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-07T03:53:00.544Z sha edf8c84 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 7, 2026
@Alix-007
Alix-007 force-pushed the alix/utf16-voice-realtime-context branch 3 times, most recently from 3b83095 to 7b5f6d8 Compare July 7, 2026 04:40
@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 Jul 7, 2026
@steipete steipete self-assigned this Jul 7, 2026
@steipete
steipete requested a review from a team as a code owner July 7, 2026 09:46
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon labels Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Dependency graph guard cleared

This PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh /allow-dependencies-change comment after the guard blocks that new head SHA.

  • Current SHA: c1bb06a35e24a89ed49004f917a2118c4479f8e2

@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Land-ready review complete on c1bb06a35e24a89ed49004f917a2118c4479f8e2.

No live provider gap: this is deterministic in-memory prompt formatting and needs no network or credentials. Thanks @Alix-007.

@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Maintainer review complete on repaired exact head c1bb06a35e24a89ed49004f917a2118c4479f8e2.

  • Rebuilt the branch cleanly on current main; the earlier corrupted 592-file ancestry is gone and the PR is back to its intended two files.
  • limitText now uses the shared plugin SDK UTF-16 helper without changing the existing cap or truncation marker.
  • The regression drives buildRealtimeVoiceInstructions and asserts exact output at a split-surrogate boundary.
  • Exact-head hosted CI (69 relevant checks), git diff --check, and fresh Codex autoreview all pass.

Ready to land.

@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

1 similar comment
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: voice-call Channel integration: voice-call P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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