Skip to content

fix(agent-runner-memory): use truncateUtf16Safe for memory flush error truncation#102685

Merged
steipete merged 3 commits into
openclaw:mainfrom
zhangqueping:fix/utf16-safe-agent-runner-memory
Jul 9, 2026
Merged

fix(agent-runner-memory): use truncateUtf16Safe for memory flush error truncation#102685
steipete merged 3 commits into
openclaw:mainfrom
zhangqueping:fix/utf16-safe-agent-runner-memory

Conversation

@zhangqueping

@zhangqueping zhangqueping commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The production UTF-16-safe memory-flush truncation fix already landed through #102823. This PR now retains the unique regression coverage needed to keep both shipped boundaries from returning to raw surrogate-splitting slices:

  • the 600-code-unit user-visible memory-flush error payload; and
  • the 200-code-unit persisted memory-flush failure message.

Relative to current main, the repaired branch is a test-only +6/-5 delta in the existing agent-runner memory integration test module.

Why This Change Was Made

The two existing behavior tests now place emoji directly across their real truncation boundaries instead of checking only long ASCII text or an uncapped generic error. This proves the existing production helper keeps complete surrogate pairs while preserving redaction, length caps, ellipses, failure counters, timestamps, and persisted session state.

The branch also removes a redundant 47-line combined test in favor of strengthening those two owner-path regressions. It does not reapply or change the production fix from #102823.

User Impact

No additional runtime behavior changes beyond #102823. The retained tests prevent future regressions that could corrupt emoji or other supplementary-plane characters in visible or persisted memory-flush errors.

Evidence

Final exact head: 6b7095f05add4ff013a48aa5981bee1667511065 (valid GitHub-verified maintainer signature; original contributor credit preserved).

  • Current-main tree comparison: src/auto-reply/reply/agent-runner-memory.ts is byte-identical; only src/auto-reply/reply/agent-runner-memory.test.ts differs (+6/-5).
  • Visible 600-unit boundary: a secret-bearing provider failure with 400 rocket emoji must stay redacted, remain at or below 600 code units, and end with the complete 🚀… suffix.
  • Persisted 200-unit boundary: a failure containing 198 ASCII code units followed by 🚀tail must persist exactly 198 ASCII code units plus , while retaining the failure count and timestamp assertions.
  • Sanitized AWS GREEN proof: Crabbox run_b8a5f2bc7e95, 47/47 focused-module tests passed on the exact hosted head with public networking, no Tailscale, no hydration, and no instance profile.
  • Exact RED control: Crabbox run_10558da929c0. Replacing only the two safe production truncations with their former raw slices made exactly the two strengthened tests fail; the harness emitted EXPECTED_RED_CONFIRMED test_exit=1 failures=2.
  • Exact-head CI: 66 passed, 0 failed, 0 pending.
  • Fresh autoreview: no accepted/actionable findings, overall confidence 0.99.
  • Static proof: oxfmt --write src/auto-reply/reply/agent-runner-memory.test.ts; git diff --check.

Known proof gaps: none for this test-only current-main delta.

Files Changed

File Change
src/auto-reply/reply/agent-runner-memory.test.ts Strengthen the two existing visible/persisted boundary regressions and remove the redundant combined test.

@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep open: the production UTF-16 truncation fix is already on current main through #102823, but this PR was intentionally reopened for unique focused regression coverage and has maintainer land-ready proof.

Root-cause cluster
Relationship: partial_overlap
Canonical: #102823
Summary: The merged canonical PR owns the production UTF-16-safe truncation fix; this PR remains open for unique focused memory-flush regression coverage.

Members:

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

Canonical path: Close this PR as superseded by #102823.

So I’m closing this here and keeping the remaining discussion on #102823.

Review details

Best possible solution:

Close this PR as superseded by #102823.

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

No current-main failure remains to reproduce: #102823 already replaced both raw slices. The PR discussion includes a red-control proof showing the strengthened tests catch the old raw-slice regression.

Is this the best way to solve the issue?

Yes for the remaining work: after the production fix landed, preserving this as a small test-only delta is the narrowest maintainable path. Reopening solely for the focused regression coverage is better than reapplying the already-merged production change.

Security review:

Security review cleared: The current useful delta is focused test coverage and the original source hunk only uses an existing internal normalization helper; no dependency, workflow, credential, or supply-chain surface changes were found.

AGENTS.md: found and applied where relevant.

What I checked:

  • linked superseding PR: fix: keep bounded Unicode text valid across UTF-16 boundaries #102823 (fix: keep bounded Unicode text valid across UTF-16 boundaries) is merged at 2026-07-09T14:21:24Z.
  • cluster evidence: the durable review links that PR in the work cluster or recommended risk path.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • steipete: He authored the merged canonical UTF-16 sweep, split the current memory-runner helper file onto main, added the current PR's focused test commits, and is assigned on the live PR. (role: recent area contributor and likely follow-up owner; confidence: high; commits: fdd19e3017ea, 5ef269c2bbfc, 6b7095f05add; files: src/auto-reply/reply/agent-runner-memory.ts, src/auto-reply/reply/agent-runner-memory.test.ts)
  • TurboTheTurtle: The related merged memory-flush-before-compaction work shaped the runtime path that now emits visible and persisted memory-flush errors. (role: adjacent feature contributor; confidence: medium; commits: e24d4426fe8c; files: src/auto-reply/reply/agent-runner.ts)

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

@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. P2 Normal backlog priority with limited blast radius. labels Jul 9, 2026
@steipete steipete self-assigned this Jul 9, 2026
zhangqueping and others added 2 commits July 9, 2026 09:13
…r truncation

Replace raw UTF-16 slices in buildMemoryFlushErrorPayload and
truncateMemoryFlushErrorMessage with truncateUtf16Safe to prevent
surrogate pair splitting in error messages shown to users.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@steipete
steipete force-pushed the fix/utf16-safe-agent-runner-memory branch from 4ea2aac to b7b2a25 Compare July 9, 2026 13:21
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Thanks @zhangqueping. #102823 landed both UTF-16-safe memory-flush error caps in 5ef269c. Update: I’m reopening this PR while we decide how best to retain its unique direct regression coverage for the persisted 200-unit and visible 600-unit memory-flush boundaries. No further action is needed from you right now.

@steipete steipete closed this Jul 9, 2026
@steipete steipete reopened this Jul 9, 2026
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Land-ready proof

Reviewed exact head 6b7095f05add4ff013a48aa5981bee1667511065.

Best-fix assessment: the production UTF-16 fix already landed in #102823. Relative to current main, this PR now contributes only focused regression coverage in the existing memory-runner test module (+6/-5): it strengthens the visible and persisted error-cap tests at surrogate boundaries and removes the redundant 47-line combined test.

Evidence:

  • Signature: the head commit has a valid ED25519 Git signature.
  • Exact-head CI: the post-reopen run passed with 66 passing checks, zero failures, and zero pending checks. The earlier attempt 2 also passed; its first attempt's only failure occurred after 1,305 tests passed, from an unrelated FsSafeError: root dir not found cleanup rejection in src/agents/apply-patch.test.ts. The same checks-node-compact-large-2 job passed on rerun.
  • Sanitized AWS green proof: 47/47 focused-module tests passed on the exact hosted head, using public networking, no Tailscale, no hydration, and no instance profile.
  • Regression red control: exactly the two strengthened tests failed after a remote-only replacement of the two safe truncations with their previous raw .slice(...) calls. The visible assertion caught the broken emoji suffix; the persisted assertion caught the lone surrogate. The harness emitted EXPECTED_RED_CONFIRMED test_exit=1 failures=2.
  • Fresh autoreview: clean, no accepted/actionable findings, overall confidence 0.99.
  • Static proof: oxfmt --write src/auto-reply/reply/agent-runner-memory.test.ts; git diff --check.

Known proof gaps: none for this test-only current-main delta.

@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Correction and current maintainer decision: #102823 superseded this PR's production changes, but exact head 6b7095f05add4ff013a48aa5981bee1667511065 retains a unique lean test-only delta for the persisted 200-unit and visible 600-unit memory-flush boundaries. It strengthens the two existing integration regressions and removes the redundant combined test.

This updated maintainer decision supersedes the stale ClawSweeper close-required marker that auto-closed the PR despite the earlier explicit reopen. The PR is being reopened for prompt native landing now; it should not be auto-closed as fully superseded.

Full exact-head CI, sanitized AWS green/red proof, signature verification, and autoreview are recorded in the land-ready proof comment, and the PR body now describes the current test-only delta. No further action is needed from @zhangqueping.

@steipete steipete closed this Jul 9, 2026
@steipete steipete reopened this Jul 9, 2026
@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 9, 2026
@clawsweeper clawsweeper Bot closed this Jul 9, 2026
@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper autoclose is complete.

Reason: structured ClawSweeper close marker: close-required (sha=6b7095f05add4ff013a48aa5981bee1667511065)

Closed:

@steipete steipete reopened this Jul 9, 2026
@steipete
steipete merged commit 921b6c1 into openclaw:main Jul 9, 2026
376 of 390 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

Simon-XYDT pushed a commit to Simon-XYDT/openclaw that referenced this pull request Jul 9, 2026
…r truncation (openclaw#102685)

* fix(agent-runner-memory): use truncateUtf16Safe for memory flush error truncation

Replace raw UTF-16 slices in buildMemoryFlushErrorPayload and
truncateMemoryFlushErrorMessage with truncateUtf16Safe to prevent
surrogate pair splitting in error messages shown to users.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* test(auto-reply): cover UTF-16-safe memory errors

* test(auto-reply): tighten UTF-16 memory error coverage

---------

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
…r truncation (openclaw#102685)

* fix(agent-runner-memory): use truncateUtf16Safe for memory flush error truncation

Replace raw UTF-16 slices in buildMemoryFlushErrorPayload and
truncateMemoryFlushErrorMessage with truncateUtf16Safe to prevent
surrogate pair splitting in error messages shown to users.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* test(auto-reply): cover UTF-16-safe memory errors

* test(auto-reply): tighten UTF-16 memory error coverage

---------

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

P2 Normal backlog priority with limited blast radius. 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