Repository navigation
fix(agents): preserve screenshots across recovery turns - #188340
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| : await loadWebMediaRaw( | ||
| targetPath, | ||
| localRoots ? { maxBytes: options.maxBytes, localRoots } : options.maxBytes, | ||
| ); |
There was a problem hiding this comment.
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 👍 / 👎.
…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.
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.
6ac91adabcc273e76a2d652a5aefc9955b0600f8: the regression failed because a later request contained noinput_image.agent-tools.prefix-stability.test.ts, image replay, sanitization, sandbox access, provider materialization, and native video transcript reopen.git diff --check: pass. No budgets or baselines changed.openclaw/ci-gateentries reportSUCCESS; 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; directgh pr checksand 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.