Skip to content

fix(facetime): keep emoji whole at the transcript entry cap - #187432

Closed
xialonglee wants to merge 1 commit into
openclaw:mainfrom
xialonglee:fix/gap-facetime-transcript-emoji-cap
Closed

xialonglee wants to merge 1 commit into
openclaw:mainfrom
xialonglee:fix/gap-facetime-transcript-emoji-cap

Conversation

@xialonglee

@xialonglee xialonglee commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a FaceTime caller's transcript entry that ends with an emoji exactly at the 2,000-character cap leaves a lone UTF-16 surrogate in the text handed to the agent consult prompt.

User Impact

User impact: emoji and other supplementary-plane characters at the FaceTime transcript cap are no longer split into invalid lone surrogates, so consult prompts always carry well-formed text.

Why This Change Was Made

The transcript entry cap used a raw slice(0, MAX_TRANSCRIPT_ENTRY_CHARS), which cuts by UTF-16 code units and can leave a lone high surrogate when an emoji straddles the cap. This was the one remaining naked text cap in the bundled FaceTime plugin; the rest of the repo was swept in the earlier "keep emoji whole at the cap" series (#186083, #181742, #182776, #101754). The cap now goes through the SDK facade truncateUtf16Safe (openclaw/plugin-sdk/text-utility-runtime), the same pattern those merges used.

Evidence

Before fix

New regression test keeps emoji whole when capping transcript entries for the consult prompt failed: the transcript entry stored for the consult prompt was a 2,000-unit prefix ending in a lone U+D83D (cut emoji).

After fix

Same test passes with the entry equal to a valid 1,999-unit prefix. Full file run: 20/20 tests pass (node scripts/run-vitest.mjs run extensions/facetime/tests/talk-driver.test.ts).

  • oxlint (--tsconfig extensions/tsconfig.json): 0 warnings, 0 errors.
  • Format check: clean.
  • Not verified locally: targeted tsgo typecheck — the tsgo native binary cannot run on this machine (glibc too old) and a full-graph tsc fallback exceeded the local time budget; CI covers the extensions type lanes.

Local diff review (openclaw-pr-review): PASSED, best-fix verdict, no findings.

Real consult-prompt chain proof (added in response to review)

A temporary vitest probe (deleted after the runs; not part of the diff) drove the shipped module graph end to end. Only the inherently external seams were stubbed — the realtime provider transport (createRealtimeVoiceBridgeSession, resolveConfiguredRealtimeVoiceProviderAsync), the macOS audio pump, and the realtime bootstrap instructions builder. Everything in the transcript-cap → consult-prompt path ran as shipped: the PR's startFaceTimeTalkDriver cap code, the real SDK transcript recording, the real openclaw_agent_consult handling in the FaceTime consult controller, the real consultRealtimeVoiceAgent session machinery (session admission + fork against an isolated createOpenClawTestState store, real runtime agent), and the real buildRealtimeVoiceAgentConsultPrompt. The exact prompt handed to the model boundary (runEmbeddedAgent) was captured.

Input transcript delivered by the provider callback: 1,999 ASCII x + 😀 (U+1F600, surrogate pair D83D DE00) + tail, final.

Command:

node scripts/run-vitest.mjs run --config test/vitest/vitest.extensions.config.ts --pool=forks facetime/tests/transcript-cap-consult-chain.proof.test.ts

(--pool=forks because the real consult session machinery opens a shared-state SQLite worker store that admits only from a main thread.)

Before fix (current-main slice cap, same chain) — the malformed entry reaches the real consult prompt:

[proof] MAX_TRANSCRIPT_ENTRY_CHARS = 2000
[proof] transcript block length = 2008
[proof] transcript block tail (JSON) = "xxxxxxxxxxxxxxxxxxxxxxx\ud83d" code points: [120,120,120,120,120,55357]
[proof] lone surrogates in whole prompt = 1

(code point 55357 = U+D83D, a lone high surrogate.)

After fix (this PR's truncateUtf16Safe cap, same chain) — the boundary-crossing emoji is dropped whole; the prompt is valid:

[proof] MAX_TRANSCRIPT_ENTRY_CHARS = 2000
[proof] transcript block length = 2007
[proof] transcript block tail (JSON) = "xxxxxxxxxxxxxxxxxxxxxxxx" code points: [120,120,120,120,120,120]
[proof] lone surrogates in whole prompt = 0

Full suite for the probe run: Tests 2 passed (2) on the PR head; on the unpatched cap the chain test fails exactly on the lone-surrogate assertion (expected 'Caller: xxx…\uD83D' to be 'Caller: xxx…').

Relates to gap finding: facetime transcript cap splits emoji (free_text, evidence level B).

@clawsweeper

clawsweeper Bot commented Oct 29, 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.

@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. 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR prevents FaceTime transcript truncation from splitting UTF-16 surrogate pairs.

Example: A final transcript contains 1,999 ASCII x characters followed by 😀 and tail.

  • Before: The 2,000-unit prefix ends with an isolated U+D83D surrogate.
  • After: The prefix contains 1,999 x characters, dropping the boundary-crossing emoji whole.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch is correct and supported by a useful regression and reported integration probe, but the required shipped-entry-point evidence remains absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A FaceTime caller's transcript can reach the agent consult prompt with an emoji split into an isolated surrogate.
Reason: The patch repairs malformed text at its producer without changing configuration, authority, public APIs, or the transcript budget.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR fixes a concrete truncation defect still present on current main, using the existing SDK helper without introducing additional machinery or a correctness finding.

Priority: P2
Reviewed head: 18325e3b78b8ef48e9735b2e101b4b650fe24040

Before merge

  • Add real behavior proof - Thanks for extending the evidence to the real transcript recorder, consult machinery, and prompt builder: the reported Vitest probe captures zero lone surrogates after the fix, but still stubs the realtime bridge and macOS audio pump and does not enter through the shipped FaceTime/Gateway runtime, so the prior proof request remains open; supply redacted runtime logs, live output, or a terminal recording of that boundary-crossing scenario, removing IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Provide the boundary-crossing transcript scenario through the shipped FaceTime/Gateway runtime and show the resulting consult prompt contains no split surrogate.
Agent review details

How this fits together

The FaceTime talk driver receives finalized realtime transcripts, bounds their in-memory history, and passes that history through the consult controller into the configured agent's prompt.

flowchart LR
  A[Realtime transcript callback] --> B[FaceTime talk driver]
  B --> C[SDK surrogate-safe truncation]
  C --> D[Bounded transcript history]
  D --> E[FaceTime consult controller]
  E --> F[Agent consult prompt]
Loading

Technical review

Best possible solution:

Retain the focused replacement with the existing surrogate-safe helper and its boundary regression.

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

The current-main slice deterministically splits 1,999 ASCII characters followed by 😀 at the 2,000-unit boundary; the contributor also reports red-before/green-after regression and prompt-chain output, which this read-only review did not execute.

Is this the best way to solve the issue?

This is the smallest complete fix: the FaceTime owner retains its existing cap and history lifecycle while delegating surrogate handling to the established SDK helper.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 80dead1a1837.

Provenance checked

  • FaceTime transcript entry cap keeps the original intent (88c56ec: The original FaceTime feature bounded individual transcript entries and total retained context for agent consults; no intentional surrogate-splitting contract was identified.)
  • Talk-driver regression coverage keeps the original intent (2431cb9: The earlier test consolidation removed redundant cases while preserving distinct regressions; this addition covers a previously untested truncation failure using existing fixtures.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Omar Shahine: Raw commit 88c56ec adds extensions/facetime/src/talk-driver.ts:87 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 88c56ec432a8; files: extensions/facetime/src/talk-driver.ts)
  • Peter Steinberger: Raw commit 9ca56ec adds extensions/facetime/src/talk-driver.ts:5 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9ca56eca6a29; files: extensions/facetime/src/talk-driver.ts)

PR surface

Source +1, Tests +30. Total +31 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 31 1 +30
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 33 2 +31

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A supplementary-plane character crossing the FaceTime transcript cap produces malformed consult context, with limited scope and no demonstrated broader outage.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add runtime evidence for the transcript-cap scenario described in the proof assessment.

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 (1 earlier review cycle)
  • reviewed 2026-10-29T07:15:01.287Z sha 18325e3 :: needs real behavior proof before merge. :: none

Reviewed October 30, 2026, 10:46 PM ET / October 31, 2026, 02:46 UTC (Revision 2).

@xialonglee

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Real behavior proof has been added to the PR body ("Real consult-prompt chain proof" section), as requested. A temporary probe drove the shipped transcript-cap → consult-prompt path end to end — only the inherently external seams (realtime provider transport, macOS audio pump, realtime bootstrap instructions) were stubbed — and captured the exact prompt handed to the model boundary:

  • Before fix: the consult prompt carried a lone U+D83D surrogate (1 lone surrogate in the whole prompt).
  • After fix: the boundary-crossing emoji is dropped whole and the prompt contains 0 lone surrogates.

Head is unchanged since the last review (18325e3). Re-verified locally today: node scripts/run-vitest.mjs run extensions/facetime/tests/talk-driver.test.ts — the full file shard passes, including the regression test keeps emoji whole when capping transcript entries for the consult prompt.

@clawsweeper

clawsweeper Bot commented Oct 31, 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 31, 2026
@xialonglee

Copy link
Copy Markdown
Contributor Author

Thanks for the re-review. Addressing the remaining proof item as far as this environment allows:

What the probe already ran as shipped (all on this PR's head): the talk driver's cap code, the real SDK transcript recording, the real openclaw_agent_consult handling in the FaceTime consult controller, the real consultRealtimeVoiceAgent session machinery (session admission + fork against an isolated store with a real runtime agent), and the real buildRealtimeVoiceAgentConsultPrompt. The exact prompt at the model boundary was captured: 1 lone surrogate before the fix, 0 after.

What cannot be exercised on this host: the probe stubs exist precisely where the runtime is inherently external to this machine — the realtime provider transport, and the macOS FaceTime audio pump/helper. FaceTime capture and the audio pump are macOS-only APIs, so no Linux host can enter this path through the fully shipped FaceTime runtime; a "real provider, shipped runtime" run still keeps the macOS audio seam stubbed here.

Given that, the remaining gap needs either a macOS host (real FaceTime runtime) or maintainer judgment. The fix itself has now been reviewed twice with zero findings, patch quality 4/6, CI green (ci-gate, prod types, lint, test types, changed-extension checks), and the full talk-driver suite passes locally on the head. Happy to help run a macOS-side capture if pointed at the expected harness.

@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the work here. We're closing this: it doesn't show a real user-facing problem (no report from an affected user and no natural reproduction), and it follows a pattern of small, speculative or duplicate changes split across many PRs. Please open an issue with a reproduction of real harm first; a fix can follow once the problem is confirmed.

@obviyus obviyus closed this Nov 16, 2026
@xialonglee
xialonglee deleted the fix/gap-facetime-transcript-emoji-cap branch November 22, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. plugin: facetime FaceTime plugin rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants