Skip to content

fix(agents): preserve screenshots across recovery turns - #188340

Merged
steipete merged 1 commit into
mainfrom
codex/history-keeps-images
Oct 30, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/history-keeps-images

Conversation

@steipete

@steipete steipete commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes screenshots disappearing from model history after an interrupted turn is replayed or the session is reopened.

User Impact

Earlier screenshot attachments remain visible to the model and keep the same serialized request prefix on later turns. No configuration changes, migrations, or user actions are required.

Why This Change Was Made

The first inline image went directly through agent image sanitization. Replay loaded the attachment through the web-media delivery optimizer and then sanitized it again. The two resize paths produced different bytes, so the session's pinned inclusion decision rejected the replayed image and replaced it with a resend notice.

Load original attachment bytes through the existing raw media loader and leave resizing to the agent sanitizer on both paths. Reuse its existing 10 MiB source limit; configured output limits and filesystem/sandbox access checks still apply. This removes the duplicate resize without adding state or changing stored data. Genuinely missing or changed attachment sources retain the existing resend behavior.

Evidence

Locally verified candidate: 78746d3872cc7b474963497be8b06b8576852058.

The existing durable request-projection regression now uses a 3064×2228 synthetic PNG, an aborted first turn, retries, later turns, and a reopened SQLite-backed session. It captures serialized OpenAI Responses requests, requires one image in every request, and compares the complete retained request prefix byte for byte.

  • Red on base 6ac91adabcc273e76a2d652a5aefc9955b0600f8: the regression failed because a later request contained no input_image.
  • Green with the fix: 108 distinct focused cases across eight files, including agent-tools.prefix-stability.test.ts, image replay, sanitization, sandbox access, provider materialization, and native video transcript reopen.
  • One fixture assertion failed during the first broader run: its temporary image lacked a workspace access declaration, so a root-access refusal prevented it from testing the intended size limit. The corrected fixture now proves sanitization rejects an impossible output size after loading successfully; its full file and affected siblings pass.
  • Regression body: 2.6 s. Existing durable projection file: 50.02 s wall; image plus stream-wrapper shard: 79.35 s; native-video shard: 117.55 s. Most wall time was cold transformation/import work; this existing durable boundary is needed to prove dispatch, persistence, and reopen together.
  • Source typecheck, targeted test typecheck, targeted lint, formatting, and git diff --check: pass. No budgets or baselines changed.
  • Codex autoreview: final candidate against the base above, P0–P2, scoped-clean with full loader, sanitizer, and hydration source supplied. No accepted/actionable findings. Author simplification pass leaves one resizing owner and no new state.
  • Production LOC delta: +1; test LOC delta: zero; documentation: +4.
  • Exact-head CI: green. Both required openclaw/ci-gate entries report SUCCESS; the full PR check set has 67 passing and 61 skipped checks, with zero failed or pending. CI run 41058887917, CodeQL, CodeQL Critical Quality, OpenGrep PR Diff, macOS Periphery, and Workflow Sanity completed successfully on the exact candidate above. The watcher encountered one relay HTTP 409 during refresh; direct gh pr checks and exact-head workflow metadata established the final result without rerunning CI.

Proof uses isolated synthetic state and captured requests with a fixture model stream. No live provider call or production Gateway was used. Coordinator owns final review and merge.

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: XS labels Oct 30, 2026
@steipete
steipete marked this pull request as ready for review October 30, 2026 12:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T12:56:48.852672Z 78746d3 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78746d3872

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +236 to 239
: await loadWebMediaRaw(
targetPath,
localRoots ? { maxBytes: options.maxBytes, localRoots } : options.maxBytes,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve format conversion when loading raw image attachments

For a local HEIC attachment whose dimensions and byte size already satisfy the agent limits, sanitizeImageBlocks verifies decodability but returns the original HEIC bytes and MIME type unchanged. Previously, loadWebMedia converted that attachment to a provider-supported format before sanitization. With this raw loader, OpenAI Responses instead replaces the image with an omission placeholder: sanitizeResponsesImagePayload uses sanitizeInlineImageDataUrl, which explicitly rejects HEIC. Consequently, previously readable attachments lose their image contents even on the first request. Move the necessary format conversion into the agent sanitizer alongside resizing rather than removing it with the delivery optimizer.

Useful? React with 👍 / 👎.

@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@steipete
steipete merged commit 31d6d8c into main Oct 30, 2026
214 of 216 checks passed
@steipete
steipete deleted the codex/history-keeps-images branch October 30, 2026 13:09
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…law#188340)

On Team (2026-10-30), a user attached a screenshot and asked the agent to fix a regression and land the PR. After the first turn stalled and was aborted, the recovery turn's history no longer carried the image: the prompt-cache diagnostics reported message 0 content[1] type/data/mimeType changed, and the cache read dropped from 299,814 to 30,318. The agent replied it could not inspect the screenshot and asked for a resend.

Cause: replay resized the stored image a second time. That changed its bytes, so the pinned history decision replaced it with a resend notice. Replay now loads the original bytes and uses the same agent sanitizer as initial submission, so earlier images stay byte-identical across requests and remain visible to the model (append-only prompt-prefix contract).

Proof at exact head 78746d3: the regression (large synthetic screenshot, aborted first turn, retries, later turns, reopened session) is red on base (a later request lacked input_image) and green here; the focused image/replay/projection suites and agent-tools.prefix-stability pass. Exact-head CI: 67 passed, 0 failed, 0 pending. Production +1 LOC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant