Repository navigation
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 27, 2026, 8:36 AM ET / 12:36 UTC. ClawSweeper reviewWhat this changesThe PR moves CJK-aware character weighting into Normalization Core and uses it when Agent Core estimates transcript tokens for compaction triggering and retained-tail selection. Merge readinessThis PR addresses a confirmed current-main compaction bug and is still necessary: current Priority: P2 Review scores
Verification
How this fits togetherAgent Core compaction estimates the token size of session messages, decides whether context is too large, and selects the recent transcript tail to retain while older content is summarized. This PR changes the shared text-size heuristic that feeds those compaction decisions for CJK-heavy user, assistant, tool, and summary content. flowchart TD
A[Session transcript entries] --> B[Agent Core token estimation]
B --> C[CJK-aware character heuristic]
C --> D[Context-size estimate]
D --> E[Compaction threshold decision]
D --> F[Retained-tail cut point]
E --> G[Summary generation]
F --> G
G --> H[Updated session context]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -17, Tests +191, Config +8. Total +182 across 10 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical CJK-aware estimator in Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main visibly applies raw UTF-16 length divided by four throughout the compaction estimator and cut-point loop, while the existing CJK helper shows the missing correction. The supplied PR evidence also records a current-main tokenizer reproduction, but this review did not independently execute it. Is this the best way to solve the issue? Yes. Reusing one CJK-aware estimator at the Normalization Core boundary and consuming it in every compaction text-accounting branch is narrower and more maintainable than introducing a compaction-only duplicate heuristic. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8d6971ecc956. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
5f3aa57 to
820eb6e
Compare
7f7abc5 to
013f2cf
Compare
013f2cf to
ceee7bd
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Co-authored-by: qingminlong <[email protected]>
|
Merged via squash.
|
) (openclaw#114386) * fix: account for CJK text in compaction estimates * fix: share CJK compaction estimator * fix: format CJK compaction estimator * fix: make CJK regexes lint-safe Co-authored-by: qingminlong <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
Closes #103930
What Problem This Solves
The compaction estimator used UTF-16 length divided by four for all text. On current main, a natural Chinese sample was estimated at 15 tokens while
o200k_basemeasured roughly 2.2–2.8 times more tokens;findCutPoint(..., 100)consequently retained about 287 actual tokenizer tokens for a 100-token target. CJK-heavy sessions could therefore miss the intended retained-tail budget and approach context overflow.Fix
Move the existing shared CJK-aware estimator into
@openclaw/normalization-coreand use it throughout agent-core compaction accounting. The weights are calibrated against realtiktoken==0.13.0measurements for botho200k_baseandcl100k_base, including natural Chinese/Japanese/Korean, decomposed Hangul, halfwidth and compatibility forms, rare BMP characters, supplementary ideographs and kana, and script-extension marks.This is the owner-boundary fix: both compaction triggering and retained-tail selection consume the same estimator, agent-core already depends on normalization-core, and the root utility now delegates to that owner instead of duplicating policy. Latin and image accounting remain unchanged.
Evidence
0a66f66dfd1747376351c2820205577056d450d5.o200k_basetokens.tiktoken==0.13.0,o200k_baseandcl100k_base, covering the Unicode categories listed above.pnpm buildand fullpnpm checkpassed on the reviewed tree.git diff --checkpassed.NO-ACTIONABLE-OBJECTION.ClawSweeper rank-up move: the branch is not rebased solely for behind-main drift because the repository landing workflow preserves hosted contributor ancestry unless merge verification finds relevant drift. Focused retained-tail proof passed on the reviewed tree; exact-head CI plus
scripts/pr prepare-runand merge verification fail closed before landing.AI-assisted: yes. The maintainer rewrite was reviewed against current main, real tokenizer measurements, sibling compaction surfaces, and contributor credit is preserved.