Skip to content

fix(qa-lab): use truncateUtf16Safe for tool search gateway and mock OpenAI text truncation#103219

Merged
steipete merged 3 commits into
openclaw:mainfrom
lsr911:fix/qa-lab-utf16-truncation
Jul 10, 2026
Merged

fix(qa-lab): use truncateUtf16Safe for tool search gateway and mock OpenAI text truncation#103219
steipete merged 3 commits into
openclaw:mainfrom
lsr911:fix/qa-lab-utf16-truncation

Conversation

@lsr911

@lsr911 lsr911 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

QA Lab's tool-search diagnostics and mock OpenAI response builder truncated text with raw UTF-16 slicing at 220, 300, 500, and 4,000-code-unit boundaries. Emoji and other non-BMP characters at those boundaries could leave lone surrogate halves in debug evidence or mock responses.

Why This Change Was Made

The five bounded prefix sites now use the canonical truncateUtf16Safe helper exposed through the public plugin SDK, following the cross-repository pattern established by #102823. The standalone helper proof was replaced with regression tests through the real tool-search lane, assertion diagnostics, and mock HTTP response paths.

User Impact

QA Lab failure diagnostics and mock OpenAI evidence responses remain well-formed when long provider, tool, or gateway text contains emoji or other non-BMP characters. Existing code-unit limits and scenario behavior are unchanged.

Evidence

  • Exact-head isolated proof at b6c6b426a6f5600582b646a438668ad56e44a46c: AWS Crabbox run run_ebcb4ec91b63 passed both focused files (136 tests total).
  • The same exact-head run built the runtime and passed the full tool-search-gateway-e2e mock-provider scenario (1/1).
  • Targeted oxfmt --check passed for all four changed files.
  • Fresh exact-head autoreview: clean, confidence 0.98.

@clawsweeper clawsweeper Bot added 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 10, 2026
@clawsweeper

clawsweeper Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 10, 2026, 6:22 PM ET / 22:22 UTC.

Summary
The PR replaces five QA Lab raw prefix slices with truncateUtf16Safe and adds integrated surrogate-boundary regressions through the tool-search fixture and mock OpenAI HTTP server.

PR surface: Source +4, Tests +124. Total +128 across 4 files.

Reproducibility: yes. from source: placing a supplementary character one UTF-16 code unit before any current cap causes raw .slice(0, N) to return a lone high surrogate. This review did not execute the tests.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: extensions/qa-lab/src/tool-search-gateway.fixture.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: canonical
Canonical: #103219
Summary: This PR is the canonical remaining fix for these exact QA Lab boundaries; merged related work addresses the same defect family on other surfaces.

Members:

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

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

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

Rank-up moves:

  • Attach redacted exact-head QA Lab runtime output or logs demonstrating the changed snippet paths with an emoji crossing each relevant boundary.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The current head has useful integrated mock and HTTP regressions, but no after-fix exact-head real QA Lab run, logs, or live output; add redacted evidence, update the PR body to trigger a fresh review, or ask a maintainer to comment @clawsweeper re-review.

Risk before merge

  • [P1] The PR discussion does not contain an after-fix exact-head execution of the changed QA Lab workflow; integrated tests and mocked HTTP paths are supplemental and do not satisfy the external-contributor real-behavior proof requirement.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the canonical helper at all five truncation boundaries with the integrated regressions, then attach redacted exact-head QA Lab runtime output or logs before merge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No actionable code defect remains established; contributor-supplied exact-head real-behavior proof is the only identified merge blocker.

Security
Cleared: The QA Lab runtime and test changes add no dependency, workflow, permission, secret, install, publishing, or package-resolution surface.

Review details

Best possible solution:

Keep the canonical helper at all five truncation boundaries with the integrated regressions, then attach redacted exact-head QA Lab runtime output or logs before merge.

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

Yes from source: placing a supplementary character one UTF-16 code unit before any current cap causes raw .slice(0, N) to return a lone high surrogate. This review did not execute the tests.

Is this the best way to solve the issue?

Yes; applying the existing shared helper at each owning truncation boundary preserves the established UTF-16-unit budgets and avoids introducing a parallel Unicode policy.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P3: The fix protects internal QA evidence and diagnostics from malformed Unicode without changing production config, protocol, persisted state, or defaults.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; 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. Needs real behavior proof before merge: The current head has useful integrated mock and HTTP regressions, but no after-fix exact-head real QA Lab run, logs, or live output; add redacted evidence, update the PR body to trigger a fresh review, or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +4, Tests +124. Total +128 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 10 6 +4
Tests 2 125 1 +124
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 135 7 +128

What I checked:

Likely related people:

  • steipete: Authored the current-head integrated boundary coverage and the recent merged repository-wide UTF-16 truncation sweep. (role: recent area contributor; confidence: high; commits: b6c6b426a6f5, 5ef269c2bbfc; files: extensions/qa-lab/src/tool-search-gateway.fixture.test.ts, extensions/qa-lab/src/providers/mock-openai/server.test.ts, extensions/qa-lab/src/tool-search-gateway.fixture.ts)
  • pick-cat: Git history attributes the central QA Lab fixture and mock-server truncation paths to the original implementation commit. (role: introduced behavior; confidence: medium; commits: 8a93d288e2f5; files: extensions/qa-lab/src/tool-search-gateway.fixture.ts, extensions/qa-lab/src/providers/mock-openai/server.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 (2 earlier review cycles)
  • reviewed 2026-07-10T09:23:56.365Z sha c376504 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-10T12:13:16.707Z sha 03d39e6 :: needs real behavior proof before merge. :: [P2] Make the UTF-16 regression proof exercise the changed paths

@lsr911

lsr911 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 10, 2026
lsr911 and others added 3 commits July 10, 2026 23:14
…xt truncation

Replace naive .slice(0, N) with truncateUtf16Safe() in:
- tool-search-gateway.fixture.ts: 4 sites (provider input snippet,
  tool output snippet, gateway output text for normal/code lanes)
- mock-openai/server.ts: 1 site (tool output evidence snippet)

LLM output text may contain non-BMP characters (emoji, CJK
extension characters). Naive .slice(0, N) at a surrogate pair
boundary produces a lone surrogate.

Co-Authored-By: Claude <[email protected]>
@steipete
steipete force-pushed the fix/qa-lab-utf16-truncation branch from 03d39e6 to b6c6b42 Compare July 10, 2026 22:15
@steipete

Copy link
Copy Markdown
Contributor

Land-ready review complete at exact head b6c6b426a6f5600582b646a438668ad56e44a46c.

  • Best-fix review: all five scoped prefix boundaries now use the public canonical helper. The disposable helper-only proof was removed in favor of tests through the real tool-search lane, assertion diagnostics, and mock HTTP response path. No findings or nits remain.
  • Hosted exact-head CI: all relevant checks passed with no failures or pending jobs.
  • Isolated fork-safe proof: AWS Crabbox cbx_0c012f520af7, run run_ebcb4ec91b63, public network with no Tailscale or hydrated credentials. Both focused files passed 136/136 tests; the full tool-search-gateway-e2e mock-provider scenario passed 1/1 after a runtime build.
  • Targeted formatting passed for all four changed files.
  • Fresh exact-head autoreview: clean, confidence 0.98.
  • Native prepare-run: passed with hosted exact-head gates; prepared SHA equals the PR head.

No known proof gaps.

@steipete
steipete merged commit 9dee9eb into openclaw:main Jul 10, 2026
103 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
…penAI text truncation (openclaw#103219)

* fix(qa-lab): use truncateUtf16Safe for tool search and mock OpenAI text truncation

Replace naive .slice(0, N) with truncateUtf16Safe() in:
- tool-search-gateway.fixture.ts: 4 sites (provider input snippet,
  tool output snippet, gateway output text for normal/code lanes)
- mock-openai/server.ts: 1 site (tool output evidence snippet)

LLM output text may contain non-BMP characters (emoji, CJK
extension characters). Naive .slice(0, N) at a surrogate pair
boundary produces a lone surrogate.

Co-Authored-By: Claude <[email protected]>

* test: add proof script for qa-lab UTF-16 safe truncation at all boundaries

* test(qa-lab): integrate UTF-16 boundary coverage

Co-authored-by: lsr911 <[email protected]>

---------

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

Labels

extensions: qa-lab P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S 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