Skip to content

fix(text): gate delivery filters on real tag shape, not bare mentions - #196624

Merged
roboclaw-bot merged 5 commits into
openclaw:mainfrom
SunnyShu0925:fix/delivery-stages-bounded-projector
Nov 12, 2026
Merged

roboclaw-bot merged 5 commits into
openclaw:mainfrom
SunnyShu0925:fix/delivery-stages-bounded-projector

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Streaming a reply that mentions relevant-memories or minimax:tool_call without emitting a real tag currently makes the delivery sanitizer re-run the canonical memories/minimax transform over the whole accumulated reply on every delta — a 64 KB reply that only mentions these words pays ~4.1 s (memories) and ~49 s (minimax) of per-append work before it completes. This PR replaces bare-word activation with one bounded tag probe shared by both delivery stages, so ordinary prose stays off the hot path while every shape the canonical transforms strip is still stripped from streamed visible text.

  • Problem: both filters used bare-word activation tokens. Any mention latched createActivatedProjector permanently; with no checkpoint, a latched stage runs text = transform(input.text) on the entire accumulated reply for every delta.
  • Solution: one createBoundedTagProjector folds each delta's whitespace runs into a bounded tail and matches a canonical-shaped regex. memoriesTextFilter uses <\s*\/?\s*relevant[-_]memories\b directly. minimaxToolCallTextFilter requires an earlier minimax:tool_call (or encoded envelope) marker plus an invocation/tag shape, because the canonical transform also removes completed <invoke> blocks whenever that marker occurs — even without an exact <minimax:tool_call> token. A bare mention has no such shape and never latches.
  • What changed: src/shared/text/assistant-visible-text.ts (the shared probe and both filter definitions), src/shared/text/assistant-visible-text.streaming-work.test.ts (whitespace-tag and batch/streaming parity cases), and the test-lines allocation. Net PR surface: **182 changed lines including deletions (172 added, 10 removed)**.
  • What did NOT change: the transform bodies (stripRelevantMemoriesTags, stripMinimaxToolCallXml) are untouched, so batch parity, syntax ownership, code protection, and recoverUnclosed streaming semantics are preserved exactly.

Why This Change Was Made

The repo invariant at model-special-tokens.ts:148-149 ("Delivery filter: batch parity through transform, bounded work through create") requires bounded work once a stage activates. These two delivery stages were the last that still latched on a bare word and re-scanned the whole reply per delta; every other stage already ships a create/checkpoint.

  • Best fix: keep the canonical transform as the single source of truth and only replace activation gating. The carried tail and the incoming delta are normalized together before truncation, so a whitespace run delivered as many one-character deltas still collapses to one space instead of pushing the opening < out of the 32-character tail. Shape and marker are latched independently and order-free: the canonical MiniMax transform needs its marker anywhere in the accumulated text, so an <invoke> shape seen before the marker must still be remembered. One character after a shape match is required, which confirms a delta-split \b boundary instead of latching on a partial tag word.
  • Alternative considered: literal tag-shaped activation tokens (the earlier revision of this PR). Rejected after review on two counts: literal tokens cannot express the parser's unbounded \s* or a tag word split across deltas, and they miss the invocation-cleanup path where a completed <invoke> block is stripped without an exact minimax envelope. A fixed-size raw tail probe was also rejected, since an unbounded whitespace run can push the < out of the window.
  • Original activation intent in both profiles is preserved: #153944 introduced selective activation to stop ordinary angle-bracket comparisons (x < y) from repeatedly rescanning a growing answer while preserving canonical parsing and delivered text; a36d0483f later reused that policy for the internal-scaffolding profile. The single shared memoriesTextFilter constant is still consumed by both profile orderings, so the two paths cannot drift. Activation remains selective — a bare mention or x < y never latches — and unlike literal tokens it restores the full parser grammar and the invocation-cleanup behavior, i.e. the "canonical parsing + delivered text" half of #153944's intent.
  • Risk: the probe holds only bounded state (a 32-character tail, one armed flag, one latch flag). Per-delta work is linear in the delta itself, not the accumulated reply. A tag word still incomplete at the end of a delta stays pending rather than latching; this is the same recoverUnclosed behavior the canonical transform already applies.

User Impact

Long streamed replies that merely discuss relevant-memories or minimax:tool_call no longer stall on a whole-reply re-scan per token. Replies containing real memory tags — including whitespace-bearing or delta-split ones — and completed minimax invocations are stripped exactly as the batch parser would strip them, so users no longer briefly see internal scaffolding that later disappears. No configuration, migration, or change to which content is stripped is required.

Compatibility

  • Preserved: bare mentions and ordinary angle-bracket prose are delivered byte-identically; real memory tags, exact minimax envelopes, encoded transport envelopes, and completed <invoke> blocks keep their existing stripping behavior; batch output is unchanged.
  • Related: selective activation origins in #153944; internal-scaffolding reuse in a36d0483f.
  • Not claimed: no change to the parser itself, no new tag syntax, and no claim about clients that bypass the shared assistant-visible projection.

Evidence

All runs below used an isolated local Gateway started from this checkout with a real configured provider, driven through the shipped chat.send RPC (so the agent turn and the assistant-visible text projection run inside the Gateway process). A GatewayClient subscribed to the broadcast chat frames. Credentials, the provider endpoint, host paths and non-public addresses are omitted; only loopback and aggregate numbers are shown.

Before / after behavior matrix

Before = the code on main before this PR (bare-word tokens). After = this PR. Reviewed head = 8dc32ed5, the RED arm for the two newly reported P2 findings; the earlier whitespace-tag and spaced-marker findings had already been fixed by that head, so their RED arms were the literal-token / 3f73a42 revisions (sections 3 and 4). Rows use the same captured Gateway delta frames (290 frames / 36,107 chars for S1, 4 frames / 299 chars for S3) or the reviewer's exact fixtures.

Workload Before (bare-word tokens) Reviewed head 8dc32ed5 After (this PR) Expected
S1 bare mention: sanitizer scan work (regexWorkChars) 122,139,945 8,754,268 9,851,722 bounded, ~12x less than Before
S1 bare mention: delivered visible chars 36,107 36,107 36,107 unchanged
S2 real <relevant-memories> tag: delivered visible chars 48 48 48 block stripped
S3 whitespace tag: delivered visible chars 165 165 165 165, block stripped (RED was the earlier literal-token revision: 299)
P2 completed <invoke> with spaced minimax marker: batch/streaming parity parity parity parity (GREEN) parity (RED was 3f73a42)
P2 whitespace run delivered as 64 single-space deltas: batch/streaming parity parity parity broken (RED) parity (GREEN) parity
P2 invocation shape before a later minimax marker: batch/streaming parity parity parity broken (RED) parity (GREEN) parity
S2/S3 batch final text across variants 82 / 198 82 / 198 82 / 198 unchanged

The After scan-work number is slightly above the intermediate PR head because the shared probe also covers the invocation-cleanup shape; it is still ~12x below Before, and the delivered text is identical in every workload.

1. Shipped-path streaming run, three source variants

$ # isolated Gateway, one variant per run; chat.send + agent.wait over the Gateway RPC
$ node --import tsx p314-chatsend.mts S1-pre && node --import tsx p314-chatsend.mts S1-head && node --import tsx p314-chatsend.mts S1-fix
{"label":"S1-pre","sendStatus":"started","waitStatus":"ok","wall":38.2,"gatewayCpuSec":52.41,"eventCount":231,"finalTextChars":28559}
{"label":"S1-head","sendStatus":"started","waitStatus":"ok","wall":41.8,"gatewayCpuSec":47.64,"eventCount":256,"finalTextChars":31313}
{"label":"S1-fix","sendStatus":"started","waitStatus":"ok","wall":46.2,"gatewayCpuSec":48.79,"eventCount":295,"finalTextChars":36107}

The chat frames were captured to JSON. replace:true frames are the Gateway's delivered visible text:

$ # S3 (whitespace-bearing memory tag), extracted from the captured chat frames
  seq 393 state delta                       ' ... < relevant-memories>\ninternal-only memory block for ops ... < / rele'   # raw provider delta
  seq 409 state delta replace=True len 198  'FIXTURE-START ... \n\n\n\nClosing paragraph ... FIXTURE-END'                  # delivered visible text (stripped)
  seq 414 state final                len 198 'FIXTURE-START ... \n\n\n\nClosing paragraph ... FIXTURE-END'

2. Reduced work on the real captured deltas

The exact delta frames broadcast by the Gateway in the S1 run were replayed through the production createAssistantVisibleStreamText("final_answer") projector. regexWorkChars counts characters passed to RegExp.prototype.test/exec — a direct proxy for whole-reply re-scan cost. Same input for all three variants:

$ node --import tsx p314-replay.mts pre  S1
{"arm":"pre","frames":290,"rawChars":36107,"visibleChars":36107,"regexWorkChars":122139945}
$ node --import tsx p314-replay.mts head S1   # reviewed head 8dc32ed5
{"arm":"head","frames":290,"rawChars":36107,"visibleChars":36107,"regexWorkChars":8754268}
$ node --import tsx p314-replay.mts fix  S1
{"arm":"fix","frames":290,"rawChars":36107,"visibleChars":36107,"regexWorkChars":9851722}

3. Whitespace-tag regression: failing on the literal-token revision, passing after repair

The same captured S3 Gateway frames replayed through the production projector on the earlier literal-token revision and on the current source. Literal tokens never activate on a whitespace-bearing opener, so the internal memory block stays in the streamed visible text; the batch transform still removes it, which was the reviewed mismatch:

$ node --import tsx p314-replay.mts pre  S3
{"arm":"pre","frames":4,"rawChars":299,"visibleChars":165,"visibleLeaksMemoryBlock":false,"visibleHasWhitespaceTag":false}
$ node --import tsx p314-replay.mts head S3      # earlier literal-token revision: RED
{"arm":"head","frames":4,"rawChars":299,"visibleChars":299,"visibleLeaksMemoryBlock":true,"visibleHasWhitespaceTag":true}
$ node --import tsx p314-replay.mts fix  S3      # after repair: GREEN
{"arm":"fix","frames":4,"rawChars":299,"visibleChars":165,"visibleLeaksMemoryBlock":false,"visibleHasWhitespaceTag":false}

Real tags (S2) strip identically on all three variants (visibleChars: 48, no leaked block).

4. P2 regression: invocation cleanup without an exact envelope

The reviewer's exact fixture — Ready.\n<minimax:tool_call >\n<invoke name="exec">secret</invoke>\n</minimax:tool_call >\nDone. — asserts batch/streaming parity (the payload must not be visible). Same assertion, same input, only the source variant changes:

$ node --import tsx p314-p2-redgreen.mts pre
arm=pre batchHasSecret=false streamingHasSecret=false parity=true assertion=PASS
exit=0 for pre
$ node --import tsx p314-p2-redgreen.mts head      # earlier exact-envelope revision: RED
arm=head batchHasSecret=false streamingHasSecret=true parity=false assertion=FAIL AssertionError: invocation payload stays visible in streamed delivery text
exit=1 for head
$ node --import tsx p314-p2-redgreen.mts fix       # after repair: GREEN
arm=fix batchHasSecret=false streamingHasSecret=false parity=true assertion=PASS
exit=0 for fix

The minimax stage's requires marker keeps a bare mention alone off the re-scan: bareMentionPreserved=true, bareMentionRegexWorkChars=2841 for the same probe.

5. The two new P2 findings: RED on the reviewed head, GREEN after repair

Both findings were reproduced with the reviewer's exact append schedules. Same acceptance condition for every arm — batch/streaming parity, with the internal payload never visible. head here is 8dc32ed5:

$ node --import tsx p314-p2new-redgreen.mts pre whitespace && node --import tsx p314-p2new-redgreen.mts head whitespace && node --import tsx p314-p2new-redgreen.mts fix whitespace
PASS arm=pre  scenario=whitespace batchHasSecret=false streamingHasSecret=false parity=true
FAIL arm=head scenario=whitespace batchHasSecret=false streamingHasSecret=true  parity=false AssertionError: internal payload stays visible in streamed delivery text
exit=1 whitespace/head
PASS arm=fix  scenario=whitespace batchHasSecret=false streamingHasSecret=false parity=true

$ node --import tsx p314-p2new-redgreen.mts pre markerLate && node --import tsx p314-p2new-redgreen.mts head markerLate && node --import tsx p314-p2new-redgreen.mts fix markerLate
PASS arm=pre  scenario=markerLate batchHasSecret=false streamingHasSecret=false parity=true
FAIL arm=head scenario=markerLate batchHasSecret=false streamingHasSecret=true  parity=false AssertionError: internal payload stays visible in streamed delivery text
exit=1 markerLate/head
PASS arm=fix  scenario=markerLate batchHasSecret=false streamingHasSecret=false parity=true

Both schedules are now pinned by added regression cases asserting not.toContain("secret") and equality with sanitizeAssistantVisibleStreamText (batch).

6. CDP CPU profiles of the Gateway process

Profiler.start/stop around each S1 turn (the turn executes inside the Gateway process), measured on the earlier revision of this PR before the probe was consolidated:

label=S1-pre-v4  profileTotal=42.20s sanitizerSelf=0.17s (0.4%)
label=S1-head-v4 profileTotal=45.50s sanitizerSelf=0.23s (0.5%)
label=S1-fix-v4  profileTotal=50.32s sanitizerSelf=0.31s (0.6%)

These columns are close across variants because a real provider emits coarse deltas (290 frames for this 36 KB reply), so the number of whole-reply re-scans is bounded by frame count even though each re-scan walks the entire accumulated reply. Process-wide self-time is too coarse to rank the variants; regexWorkChars in section 2 is the direct measure and was re-run on the final source for every row in the table above. On a client receiving one-character deltas (as in the original 64 KB measurement) the same ~12x ratio applies to every one of tens of thousands of appends, which is where the multi-second stalls come from.

7. Focused regression assertion and suites

$ node --import tsx p314-redgreen.mts head       # earlier literal-token revision: RED
FAIL arm=head: frames=4 visibleChars=299 AssertionError: internal memory block is still visible in streamed delivery text
exit=1 for head
$ node --import tsx p314-redgreen.mts fix        # after repair: GREEN
PASS arm=fix: frames=4 visibleChars=165 internal memory block stripped from streamed delivery text
exit=0 for fix

$ CI=1 vitest run src/shared/text/assistant-visible-text.streaming-work.test.ts src/shared/text/assistant-visible-text.minimax.test.ts src/shared/text/tool-call-xml.streaming-work.test.ts
 Test Files  3 passed (3)
      Tests  150 passed (150)

The expectPrefixParity case checks the spaced-marker P2 fixture at every delta split against sanitizeAssistantVisibleStreamText (batch), so the streaming path cannot drift from batch. Two further cases pin the newly reviewed schedules — a whitespace run delivered as 64 single-space deltas, and an <invoke> shape arriving before the minimax marker — each asserting both payload removal and equality with the batch transform. The original whitespace cases still cover a split opener/closer and an unbounded gap (4,096 then 2,048 spaces) in a single append. The low-value plain real-MiniMax-envelope case was removed on review feedback; assistant-visible-text.minimax.test.ts already streams complete envelopes in four-character chunks with surrounding prose assertions. oxfmt --check and oxlint --type-aware report 0 warnings and 0 errors on both changed source files.

CI attribution

Two CI failures were attributed and fixed:

  • checks-fast-baseline-ratchets / test-lines: the first run reported over by: 7; net delta: +96 (the allocation under-funded the added test lines); the second run reported Test line allocation credit 92 exceeds allowed ceiling growth 85 (the credit exceeded the new net delta). The allocation is now set to exactly the net test-line delta of this revision (109). Locally, in both --staged and working-tree modes, check-test-lines-ratchet reports Test lines OK: 6613703; ceiling: 6613733; slack: 30 and check-line-cap-ratchet reports no new violations; the CI run on this head passed checks-fast-baseline-ratchets.
  • checks-ui-e2e (1/2): a page.waitForFunction: Timeout 30000ms exceeded in ui/src/e2e/screen-requester-routing.e2e.test.ts (mock-Gateway Control UI browser test, 80 passed / 1 failed / 1 skipped), waiting on a tools.github.status request during GitHub-identity setup navigation. It is not caused by the shared-text changes here (this PR does not touch any ui/ file, and the timeout is in a Control-UI routing flow unrelated to assistant text). The same test fails on unrelated PRs that also do not touch ui/ — e.g. PR fix(memory): stream session memory exports in bounded pages #196480 (6b5c7e4396) and PR perf(sandbox): avoid full content hashing after workspace imports #196937 (56845faf22) both report checks-ui-e2e (1/2): failure with the identical timeout. The repository's rerun endpoint requires admin rights, so this upstream-flaky job is left for a normal CI retry. Scan changed paths (precise), the six Security High CodeQL shards and Select Critical Quality shards in earlier runs were GitHub installation API rate-limit errors, i.e. infrastructure.

PR context and evidence is success on the latest head, and vitest reports 150/150 passing across assistant-visible-text.streaming-work, assistant-visible-text.minimax and tool-call-xml.streaming-work; oxfmt --check and oxlint --type-aware report 0 warnings and 0 errors.

What was not tested

  • The Gateway proof used one real provider and loopback transport; no remote or multi-node Gateway topology was exercised.
  • CPU profiles are process-wide; regexWorkChars is the isolated measure of sanitizer scan cost, not end-user wall-clock time.
  • No streaming replies larger than ~36 KB were measured on the shipped path; the 64 KB figures come from the isolated single-stage measurement.

Open PR collision check

Searched open PRs by changed-file list for src/shared/text/assistant-visible-text.ts and src/shared/text/assistant-text-transforms.ts: apart from this PR (#196624), none of the matching open PRs (#192357, #181990, #196690, #143937, #191562) modifies either file. The related sibling PR #193871 (closed legacy-bracket checkpoint settlement) is a separate root cause in a different subsystem and remains its own open PR.

@clawsweeper

clawsweeper Bot commented Nov 10, 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. P2 Normal backlog priority with limited blast radius. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR activates memory and MiniMax delivery filters only after a bounded probe detects relevant tag syntax.

Example: A streamed reply contains 36,107 characters discussing relevant-memories and minimax:tool_call without emitting tags.

  • Before: The supplied replay records 122,139,945 characters of regex scan work.
  • After: The supplied replay records 9,851,722 characters of regex scan work, preserving all 36,107 visible characters.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, useful repair with shipped-path terminal evidence, preserved canonical parsing, and all prior findings addressed; required CI remains pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The full body supplies isolated Gateway chat.send runs with a real provider and delivered chat frames for bare mentions and real memory tags, plus identical-input production-projector replays demonstrating reduced scan work and red/green coverage of both latest repairs.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Long streamed replies can stall while merely discussing memory or MiniMax tag names.
Reason: The supplied work-count comparison demonstrates reduced unnecessary scans while preserving visible text, parser ownership, configuration, and defaults.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses a current-main streaming performance defect, resolves the prior findings, and has no remaining actionable correctness findings; required CI is still pending.

Priority: P2
Reviewed head: 4600092244da52d23f4cf3db8ee58c5371a43536

Before merge

None.

Findings

None.

Agent review details

How this fits together

Provider text deltas enter the agent's shared text projection, which removes internal scaffolding and emits visible text as append deltas or replacement snapshots.

flowchart LR
  A[Provider text deltas] --> B[Agent message update handler]
  B --> C[Assistant visible text projection]
  C --> D[Bounded tag activation probes]
  D --> E[Canonical text transforms]
  E --> F[Visible deltas or replacements]
Loading

Technical review

Best possible solution:

Retain the shared bounded activation probe and unchanged canonical parsers, then land this PR after required current-head CI passes.

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

Current-main activation tokens and projector control flow establish the repeated-scan path, supported by the contributor's before/after Gateway and replay output; this read-only review did not execute it.

Is this the best way to solve the issue?

The change fixes activation at the existing shared owner, preserves canonical parsing and replacement resets, and addresses both prior findings without introducing a competing sanitizer.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Memory and MiniMax selective activation keeps the original intent (da96eb5: Avoid rescanning growing comparison prose while preserving canonical filtering; the originating PR acknowledged bare-marker activation as a remaining case.)
  • Internal-scaffolding memory stage keeps the original intent (a36d048: Separate streaming transforms from dormant UI presentation while preserving existing grammar and literal protection.)
  • MiniMax streaming recovery keeps the original intent (a8771d6: Prevent quoted invocation closers from exposing tool arguments and preserve separate streaming versus terminal recovery behavior.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Reviewed introduction: The pinned merge-base-to-head diff changes activation gating, adds focused streaming regressions, and supplies their test-line allocation; canonical transform bodies remain unchanged. (src/shared/text/assistant-visible-text.ts:84, 4600092244da)
  • Current main still needs the fix: Current main uses bare relevant-memories and minimax:tool_call activation tokens; createActivatedProjector latches them and invokes non-checkpointed transforms over accumulated text. (src/shared/text/assistant-visible-text.ts:123, e212edede209)
  • Prior findings resolved: The latest commit normalizes carried whitespace together with incoming deltas and independently latches marker and invocation shape; dedicated regressions cover both previously failing append schedules. (src/shared/text/assistant-visible-text.ts:97, 4600092244da)
  • Original activation intent: Merged improve(agents): reduce repeated filtering of streamed comparison text #153944 introduced selective activation to reduce comparison-text rescans while preserving delivered text; its body explicitly acknowledged that bare marker names could still activate filters. (src/shared/text/assistant-visible-text.ts, da96eb57e162)
  • Supplied behavior proof: The full PR body supplies isolated Gateway chat.send output with a real provider, delivered chat frames, identical-input replay comparisons, red/green results for the prior findings, and 150 passing focused tests; terminal output is sufficient for this text-processing change. (4600092244da)
  • Exact-head gates: GitHub reports mergeable=true; the required aggregate remains pending, and the inspected check runs contain no failure, timeout, or action-required conclusion. (4600092244da)

Likely related people:

  • Peter Steinberger: Raw commit 6c1dde5 adds src/shared/text/assistant-visible-text.ts:765 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6c1dde5291ad; files: src/shared/text/assistant-visible-text.ts)
  • Jason Cat: Raw commit 752ad78 adds src/shared/text/assistant-visible-text.streaming-work.test.ts:5 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 752ad78253c2; files: src/shared/text/assistant-visible-text.streaming-work.test.ts)

PR surface

Source +44, Tests +109, Other +9. Total +162 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 54 10 +44
Tests 1 109 0 +109
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 9 0 +9
Total 3 172 10 +162

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test LOC Production +54/-10; tests +109/-0 The production growth supplies one bounded activation implementation shared by two filters; tests cover scan work, parser-compatible tag shapes, whitespace fragmentation, and marker ordering.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Long replies mentioning internal tag names trigger avoidable cumulative sanitizer work; the fix has clear value without evidence of an urgent widespread outage.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (3 earlier review cycles)
  • reviewed 2026-11-10T11:19:43.613Z sha a76ee5088da05e58e9fc021cca71530c5bce0ccd :: needs real behavior proof before merge. :: [P2] Preserve whitespace-tolerant memory-tag activation
  • reviewed 2026-11-11T01:40:57.715Z sha 3f73a42 :: needs changes before merge. :: [P2] Preserve MiniMax invocation cleanup without an exact envelope
  • reviewed 2026-11-11T02:37:44.698Z sha 8dc32ed :: needs changes before merge. :: [P2] Fold whitespace across delta boundaries before truncating the tail | [P2] Remember invocation shapes that arrive before the MiniMax marker

Reviewed November 10, 2026, 10:17 PM ET / November 11, 2026, 03:17 UTC (Revision 4).

The relevant-memories and minimax delivery filters used bare word
activation tokens ("relevant-memories" / "minimax:tool_call"). Under
createActivatedProjector the probe latches on the first mention and the
canonical transform then re-scans the whole accumulated reply on every
delta. Gate activation on the real <relevant-memories> / <minimax:tool_call>
tag shapes so ordinary replies that merely mention the words never pay the
whole-reply re-scan.
@SunnyShu0925
SunnyShu0925 force-pushed the fix/delivery-stages-bounded-projector branch from a76ee50 to bc17aa9 Compare November 10, 2026 11:34
…bounded probe

The canonical memory parser accepts <\s*\/?\s*relevant[-_]memories, but
literal activation tokens only matched the exact '<relevant-memories' shape.
A whitespace-bearing opener or a tag word split across deltas never latched
the delivery stage, so the memory block stayed in the streamed visible text
while the batch transform removed it.

Replace the literal tokens with a bounded incremental probe that mirrors the
parser grammar (unbounded whitespace, optional slash, split tag word, word
boundary). Ordinary prose and bare mentions still never latch, so the
whole-reply re-scan stays off the hot path for both delivery and
internal-scaffolding profiles.
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Nov 11, 2026
Review follow-up: literal activation tokens missed the canonical MiniMax
invocation-cleanup path (a completed <invoke> block with a spaced minimax
marker but no exact envelope), leaving the payload visible in streamed text
while batch filtering removed it.

Replace the separate per-stage state machines with one bounded tag projector
that folds each delta's whitespace runs into a fixed-size tail, so the
canonical \s* grammar stays representable across unbounded gaps and delta
splits. The minimax stage additionally requires an earlier marker word before
an invocation/tag shape can activate, keeping bare mentions off the
whole-reply re-scan while restoring batch/streaming parity.

Also remove the redundant plain MiniMax-envelope case (already covered in
assistant-visible-text.minimax.test.ts) and add a batch/streaming parity
case for the reviewed invocation-cleanup shape.
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

…rder-free

Review follow-up on the two remaining P2 findings:

- Whitespace was collapsed within each delta separately, so a whitespace run
  delivered as many one-character deltas still pushed the opening '<' out of
  the bounded tail. Normalize the carried tail and the incoming delta together
  before truncation.
- The MiniMax marker was required to appear before an invocation shape, but
  the canonical transform needs its marker anywhere in the accumulated text.
  Latch the shape and the marker independently, order-free, while a bare
  mention alone still satisfies neither.

Add a regression case for each reviewed append schedule, asserting payload
removal and batch parity, and align the test-lines allocation with the net
test-line delta.
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 11, 2026
@SunnyShu0925
SunnyShu0925 marked this pull request as draft November 11, 2026 03:25
@SunnyShu0925
SunnyShu0925 marked this pull request as ready for review November 11, 2026 03:26
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

Follow-up on the two P2 findings and the CI exception:

  • Both P2 findings fixed. The reviewed head (8dc32ed5) left two activation regressions: (1) a whitespace run split across many appends pushed < out of the bounded tail, so a memory block stayed in streamed text; (2) an <invoke> shape arriving before the minimax marker was not remembered. Both are now reproduced as RED (reviewed head) → GREEN (this head) in the body's evidence (p314-p2new-redgreen.mts, pinned by added regression cases asserting payload removal + equality with sanitizeAssistantVisibleStreamText).
  • checks-fast-baseline-ratchets / test-lines now green on this head (allocation set to the exact net test-line delta, 109).
  • checks-ui-e2e (1/2) is an upstream issue, not from this PR. This PR does not touch any ui/ file, and the timeout is on a tools.github.status request during Control-UI GitHub-identity navigation — unrelated to assistant text. The same test fails identically on unrelated PRs that also don't touch ui/: fix(memory): stream session memory exports in bounded pages #196480 (6b5c7e4396) and perf(sandbox): avoid full content hashing after workspace imports #196937 (56845faf22) both report checks-ui-e2e (1/2): failure with the same 30s waitForFunction timeout. The rerun endpoint needs admin rights, so it's left for a normal CI retry.

@SunnyShu0925
SunnyShu0925 force-pushed the fix/delivery-stages-bounded-projector branch from 076ff9b to efac72b Compare November 12, 2026 00:57
@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Nov 12, 2026
@roboclaw-bot
roboclaw-bot merged commit 1274f85 into openclaw:main Nov 12, 2026
117 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…openclaw#196624)

Avoid repeated canonical memory/MiniMax scans when a streamed reply only mentions tag names. Bounded shape probes preserve canonical parsing, split-whitespace tags, and marker ordering.

Reviewed head: efac72b. Focused validation: 3 files / 150 tests passed. Local autoreview of 8f593cd..efac72b through P2 completed scoped-clean. Supplied Gateway proof is reused; scan-work improvement is not a wall-clock latency claim.

Thanks @SunnyShu0925.

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

Labels

clawtributors PR from a clawtributor P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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