Skip to content

fix(compaction): record omitted images instead of dropping them silently - #131977

Merged
steipete merged 4 commits into
mainfrom
steipete/compaction-image-marker
Aug 29, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/compaction-image-marker

Conversation

@steipete

@steipete steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

When a session was compacted, images vanished from the summarization input with no trace. The compaction serializer returned an empty string for image blocks, and the surrounding logic then skipped now-empty user messages and tool results entirely — so an image-only turn (or an image-only tool result, e.g. a screenshot) contributed nothing to the summary and left no marker. After compaction the model could not distinguish "an image was here and was omitted" from "no image ever existed", which is exactly the silent-drop class the repo doctrine ranks worst: an action must end in a visible outcome or a recorded non-outcome.

Confirmed reachable on shipped v2026.7.1-2, not just main.

Why This Change Was Made

The canonical serializer now records the omission before the empty-content check, so the fact survives instead of the content being dropped. Deliberately minimal and bounded:

  • The image marker is byte-for-byte the literal already used by history-image-prune ([image data removed - already processed by model]) rather than a second dialect; other omitted non-text blocks use the same shape with non-text data. (Agent-core cannot import the host runner, so the literal is duplicated, not shared.)
  • Built-in summarizer input receives at most 847 added UTF-8 bytes of omission records per request, including newly retained role labels and separators: the first eight affected messages receive deduped markers, later omissions receive one aggregate statement, and the records count toward token estimates without asserting prior model processing. No image data or metadata is ever rendered. An earlier revision of this body claimed only a per-message bound; that was wrong, because nothing capped the number of messages. Deep review measured the unbounded growth (~59 bytes per image-only message) and the prompt-wide cap was added in response.
  • Markers are emitted outside tool-text truncation, so a long tool result cannot truncate away the omission fact.
  • A duplicate tool-result serialization branch was removed in favour of one combined user/tool-result path.

Why the nearby correct-looking code doesn't already cover this: history-image-prune does insert proper markers, but its transform rewrites the provider projection, whereas compaction re-reads the original manager branch via sessionManager.getBranch(). The compaction safeguard preserves the last three user turns with placeholders but still routes older messages and split-turn prefixes through the defective serializer.

User Impact

After a compaction, summaries and rebuilt context state that an image was omitted instead of silently losing it. Thresholds, retention, summarizer instructions, original transcript rows, schema, and persistence ownership are untouched, and custom compaction providers (which receive original arrays) are unaffected. Token accounting does change: omission records are now included in the estimate rather than left outside it. This establishes request bytes and deterministic replay plumbing; it does not guarantee what a model retains in its generated summary.

Evidence

  • Failing-first through real prepareCompaction → compact → buildSessionContext with an image-only user message, an image-only tool result, and a split-turn prefix (pre-fix: image serializes to "", no marker anywhere in the summarization input or rebuilt context).
  • Deep review kept the production fix unchanged and added a follow-up that enforces the exact marker bounds as a test invariant; it attempted and failed to construct a counterexample that renders payload/metadata into a marker.
  • Assistant private-reasoning omission, the safeguard's last-three-turns placeholders, and history-image-prune's own marker path verified untouched.
  • Post-rebase agent-core compaction suites green; explicit-path changed-file gate exit 0; two Codex autoreviews clean.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 28, 2026 17:40
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S maintainer Maintainer-authored PR labels Aug 28, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 12:26 AM ET / 04:26 UTC.

ClawSweeper review

What this changes

This PR records bounded text markers for image and other non-text content omitted from built-in compaction summaries, while preserving image token pressure.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

No introduced correctness finding: the PR repairs the canonical text-summary projection and remains needed because fetched main retains the prior silent-drop behavior. Its maintainer label and member authorship require an explicit maintainer decision after the current review context and checks are complete.

Priority: P1
Reviewed head: dd74b4a0d466707fae28cee0b56771c545ed4b71
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and well-covered across its shared owner boundary, with maintainer-context confirmation still needed before merge.
Proof confidence 🌊 off-meta tidepool Not applicable: The changed production owner is the compaction serializer, exercised in supplied tests through normal, split-turn, and branch entrypoints; the supplied evidence is injected-runtime test evidence rather than a live trace, but the external-contributor proof gate does not apply to the member-authored PR.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The changed production owner is the compaction serializer, exercised in supplied tests through normal, split-turn, and branch entrypoints; the supplied evidence is injected-runtime test evidence rather than a live trace, but the external-contributor proof gate does not apply to the member-authored PR.
Evidence reviewed 8 items Current-main behavior: Fetched main retains the pre-PR serializer: image-only user and tool-result content produces no serialized text and is skipped.
Still-needed comparison: Fetched main has no compaction-path changes relative to the PR base, so it has not independently absorbed this fix.
Canonical repair owner: The introduced helper records only omission categories, preserves text, and bounds detailed records to eight affected messages plus one aggregate record.
Findings None None.
Security None None.

How this fits together

Compaction converts older session history into text summaries for future model turns. Session entries feed the serializer, whose output is sent to normal, split-turn, and branch summarizers before the resulting summary re-enters session context.

flowchart LR
  A[Persisted session history] --> B[Compaction preparation]
  B --> C[Text summary serializer]
  C --> D[Normal and split summaries]
  C --> E[Branch summaries]
  D --> F[Saved compaction summary]
  E --> F
  F --> G[Next model context]
Loading

Decision needed

Question Recommendation
After confirming the current ClawSweeper comment contains no unresolved rank-up move and the body reflects the distinct marker wording, should this compaction repair be approved once exact-head checks finish? Approve after context check: Confirm the current review comment and correct the marker-rationale prose, then use the completed exact-head checks to proceed.

Why: This member-authored PR carries the protected maintainer label, and filtered review comments prevent automation from determining whether intervening maintainer direction exists.

Before merge

  • Resolve merge risk (P1) - The PR body says the new image marker is byte-for-byte the history-pruning marker, but the introduced marker deliberately uses different wording; correct that rationale before merge.
  • Resolve merge risk (P1) - The latest ClawSweeper comment and two captured PR comments were unavailable in this review context, so their maintainer direction and any current rank-up moves must be checked before landing.
  • Resolve merge risk (P1) - Production code is net +16 lines; that growth is tied to the shared omission projection and prompt-wide hard cap after removing duplicated serialization branches.
Agent review details

Security

None.

PR surface

Source +16, Tests +328, Docs +2, Other 0. Total +346 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 56 40 +16
Tests 2 333 5 +328
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 6 392 46 +346

Review metrics

Metric Value Why it matters
Production versus test delta production +56/-40 (net +16); tests +333/-5; docs +2 The modest production growth implements the bounded shared projection; most of the change is focused regression coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one shared serializer for all built-in summary paths, correct the PR-body marker rationale, and land only after the current maintainer review context and exact-head checks are satisfied.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one shared serializer for all built-in summary paths, correct the PR-body marker rationale, and land only after the current maintainer review context and exact-head checks are satisfied.

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

Yes, from source: fetched main serializes image-only user and tool-result content to an empty string and skips it, while the introduced tests exercise the same preparation-to-summary path. This review did not execute the tests.

Is this the best way to solve the issue?

Yes. The repair belongs in the one serializer shared by normal, split-turn, and branch summaries, rather than duplicating image markers in each caller or reusing the provider-prompt history-pruning transform.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1b2ce27355b8.

Labels

Label justifications:

  • P1: The PR addresses silent loss of image-presence context during a core agent compaction workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The changed production owner is the compaction serializer, exercised in supplied tests through normal, split-turn, and branch entrypoints; the supplied evidence is injected-runtime test evidence rather than a live trace, but the external-contributor proof gate does not apply to the member-authored PR.

Evidence

What I checked:

Likely related people:

  • steipete: Available blame and history attribute the existing compaction token path and all PR commits to Peter Steinberger. (role: current implementation author and recent area contributor; confidence: high; commits: 548c9f2ac4c3, 73edc16728f1, dd74b4a0d466; files: packages/agent-core/src/harness/compaction/compaction.ts, packages/agent-core/src/harness/compaction/utils.ts)

Rank-up moves

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

  • Correct the PR-body statement that says the new marker matches history-image-prune byte-for-byte, then verify the latest ClawSweeper comment before landing.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-08-28T17:46:43.522Z sha 9d86681 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T18:19:28.440Z sha 9d86681 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T21:15:32.307Z sha dfcca259f2f8b088ee86d8059add3e225ca9727a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T21:44:07.461Z sha 3d16345 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T22:57:36.578Z sha 08fde19 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T03:33:55.805Z sha 0e10db7 :: needs maintainer review before merge. :: none

@steipete steipete closed this Aug 28, 2026
@steipete steipete reopened this Aug 28, 2026
@steipete
steipete force-pushed the steipete/compaction-image-marker branch 3 times, most recently from 08fde19 to 0e10db7 Compare August 29, 2026 03:24
Record bounded image and non-text omission markers in text-only summarization input, including image-only user messages and tool results. Reuse the history-pruning image vocabulary without changing token estimates, retention, original transcript rows, or private reasoning handling.
Prove that image and non-text markers add exactly 103 characters without changing visible text or tool-result truncation. Exercise misleading metadata, long unknown type names, and non-text-only messages interspersed with empty messages to protect per-message omission tracking.
Cap omission details across each summarizer request and preserve one aggregate overflow fact. Count the records in token estimates while preserving image pressure, and describe omission without claiming prior model processing. Repair findings 1 and 3 for PR #131977.
@steipete
steipete force-pushed the steipete/compaction-image-marker branch from 0e10db7 to dd74b4a Compare August 29, 2026 04:17
@steipete
steipete merged commit 5e135e3 into main Aug 29, 2026
155 checks passed
@steipete
steipete deleted the steipete/compaction-image-marker branch August 29, 2026 04:56
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 30, 2026
…tly (openclaw#131977)

* fix(compaction): record omitted images instead of dropping them silently

Record bounded image and non-text omission markers in text-only summarization input, including image-only user messages and tool results. Reuse the history-pruning image vocabulary without changing token estimates, retention, original transcript rows, or private reasoning handling.

* test(compaction): enforce exact omission marker bounds

Prove that image and non-text markers add exactly 103 characters without changing visible text or tool-result truncation. Exercise misleading metadata, long unknown type names, and non-text-only messages interspersed with empty messages to protect per-message omission tracking.

* test(compaction): use synthetic model naming in image fixtures

* fix(compaction): bound and account for summary omission records

Cap omission details across each summarizer request and preserve one aggregate overflow fact. Count the records in token estimates while preserving image pressure, and describe omission without claiming prior model processing. Repair findings 1 and 3 for PR openclaw#131977.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant