Skip to content

fix: label conversation data in system updates - #206840

Merged
roboclaw-bot merged 5 commits into
openclaw:mainfrom
VACInc:label-system-context
Nov 27, 2026
Merged

roboclaw-bot merged 5 commits into
openclaw:mainfrom
VACInc:label-system-context

Conversation

@VACInc

@VACInc VACInc commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

A screening plugin already sees the full embedded model request. When a system update contains both OpenClaw instructions and a quote from chat, the plugin has no reliable way to tell which characters are the quote. Guessing can redact instructions or leave part of the quote untouched.

User Impact

Plugins already allowed to use before_model_request can use optional contextSpans to screen just the quoted conversation data. There is no new opt-in, automatic scanner, or change to the provider request unless a plugin rewrites it. Older saved updates still load without labels. Missing or unmatched labels never mean the text is trusted.

Why This Change Was Made

The renderer records quote boundaries while it still knows the source of each piece. The embedded runner keeps the positions attached to that exact text, adjusts them for ordinary provider replacements, and withholds uncertain positions instead of guessing. The worker protocol and its generated validator accept the optional ranges and the existing fallback replay marker.

Evidence

Latest stable → tested PR runtime 5bf8fcaa: passed. The only subsequent change changes a browser test's clock, not application code, dependencies, or persisted formats. In a fresh isolated AWS VM, the integrity-verified npm release [email protected] served a real Gateway. chat.send and agent.wait completed a turn, and chat.history returned the saved user message and assistant reply. The released session SDK also wrote an old-format hidden system update to that same chat: turnScoped: true, replay: "append", no dataRanges. No database rows were hand-edited.

We stopped the stable Gateway and started the built PR Gateway on the same state directory and unchanged config, with no manual migration. It reopened the same session ID and preserved the original user and assistant content, the hidden update's text, timestamp, and metadata. A second real Gateway turn completed and persisted. The loopback model fixture received both the old and new chat in the outgoing request. This exercised actual released and candidate binaries, the embedded agent and SQLite; only the external inference service was a fixture. No paid provider call was made.

  • Quote regression: on 007b587e, after a length-changing provider rewrite, the scanner selected part of the instruction label instead of "ocean blue 📎". In the repaired test, the real OpenAI Responses encoder and plugin hook redact only the quote and preserve both adjacent instructions, before and after reopening SQLite.
  • Focused checks: 37 tests passed across four provider, hook, rewrite and worker-transcript files (123 seconds including compilation). The repaired source also passed targeted lint, formatting, the root-test TypeScript check and Gateway validator verification. The native PR wrapper import-inventory and cold-provisioning tests and the repository commit guard passed.
  • Required browser check: reproduced the old dashboard failure by delaying the test controller 2.3 seconds while the connection remained pending. The corrected test controls browser time before reload and advances it explicitly. Both the chat and dashboard passed in Chromium with that delay and without it: the badge was absent at boot, appeared after the grace period, and did not move the layout. No UI product code changed.
  • Local autoreview could not start its executable in the required read-only sandbox and produced no verdict. See the GitHub checks and hosted ClawSweeper review for the final commit.

Original change by @VACInc.

@clawsweeper

clawsweeper Bot commented Nov 27, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Nov 27, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. clawsweeper:intake:feature Preliminary submission classification; full source review pending. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR exposes producer-labelled conversation quote ranges to plugins screening embedded model requests.

Example: A system update contains both the instruction Keep the label "blue 📎". and a separate quote blue 📎, then a provider replacement changes blue to ocean blue.

  • Before: The screening plugin cannot reliably distinguish the quoted conversation text from the instruction.
  • After: The plugin receives offsets identifying only "ocean blue 📎" in the conversation-data block and can redact it while preserving adjacent instructions.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is coherent and has meaningful boundary coverage, but supplied runtime evidence does not exercise the new screening capability.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: A screening plugin cannot reliably isolate quoted chat text from adjacent OpenClaw instructions in a system update.
Reason: The maintainer-authored direction supplies information available at the producer through an existing hook, without adding configuration, automatic scanning, or permission changes.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: it adds useful quote metadata through the existing screening hook, and no definite correctness defect was found.

Reviewed head: 9e0cb330b5c04e026311422d02b9f57cef18fe54

Before merge

None.

Findings

None.

Agent review details

How this fits together

Runtime-context producers assemble instructions and conversation data; transcript projection and provider text transforms carry quote boundaries to the final request hook, where an already-enabled plugin can rewrite outgoing content.

flowchart LR
  A[Runtime fragments] --> B[Context renderer]
  B --> C[Stored system update]
  C --> D[Message projection]
  D --> E[Provider text transforms]
  E --> F[Model request hook]
  F --> G[Provider payload]
Loading

Technical review

Best possible solution:

Keep quote boundaries at the existing renderer and request hook, preserving optional legacy-compatible metadata and omitting ranges when rewrites make them uncertain.

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

This is an extension capability: current main renders mixed instructions and conversation data but supplies no producer-labelled quote offsets to the final request hook.

Is this the best way to solve the issue?

The implementation extends the existing owners, preserves rendered text and authorization, and conservatively drops uncertain ranges instead of introducing a competing scanner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vito Cappello: Raw commit 2b7950c adds src/agents/embedded-agent-runner/model-request-hook.ts:44 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2b7950cae3c3; files: src/agents/embedded-agent-runner/model-request-hook.ts)
  • Peter Steinberger: Raw commit 46ab36a adds src/agents/embedded-agent-runner/run/runtime-context-prompt.ts:154 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 46ab36a493ac; files: src/agents/embedded-agent-runner/run/runtime-context-prompt.ts)
  • Dallin Romney: Raw commit cd9913f adds src/agents/internal-runtime-context.ts:48 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cd9913f1b110; files: src/agents/internal-runtime-context.ts)

PR surface

Source +180, Tests +146, Docs +9, Other +1. Total +336 across 17 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 10 1979 1799 +180
Tests 5 154 8 +146
Docs 1 10 1 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 17 2144 1808 +336

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
Plugin contract addition 1 optional hook field; 0 new configuration options Existing handlers remain source-compatible and operators retain the existing hook opt-in.

Labels

Label changes:

No label changes.

Label justifications:

  • merge-risk: 🚨 compatibility: The PR extends a public plugin event and persisted system-update metadata; optional fields, legacy replay coverage, and the stable-upgrade report address existing-state compatibility.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Supply the focused Gateway screening trace 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 (3 earlier review cycles)
  • reviewed 2026-11-27T17:35:39.010Z sha 4e8459d :: blocked before merge. :: [P1] [P1] Preserve worker compatibility when persisting data ranges
  • reviewed 2026-11-27T19:12:10.121Z sha a36bda8 :: blocked before merge. :: none
  • reviewed 2026-11-27T19:42:24.305Z sha 5bf8fca :: passed. :: none

Reviewed November 27, 2026, 2:56 PM ET / 19:56 UTC (Revision 4).

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime labels Nov 27, 2026
Carry origin-labelled ranges through literal replacements, discard uncertain boundaries, and keep older worker updates readable. Verify redaction at provider I/O before and after a SQLite reopen.

Co-authored-by: VACInc <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Nov 27, 2026
The PR wrapper materializes the text transform and its runtime imports. Include the new range binding so a fresh worktree can load it.

Co-authored-by: VACInc <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Nov 27, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Nov 27, 2026
Keep the browser clock paused while the test loads the saved conversation and fonts. Advance it to test the slow state instead of depending on CI wall time. No production UI changes.

Co-authored-by: VACInc <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@roboclaw-bot
roboclaw-bot merged commit 179e0c4 into openclaw:main Nov 27, 2026
168 of 169 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL 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