Skip to content

fix: retain photos on later sandbox conversation turns - #179301

Merged
steipete merged 3 commits into
mainfrom
fix/sandbox-history-media-staged-provenance
Oct 21, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/sandbox-history-media-staged-provenance

Conversation

@steipete

@steipete steipete commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #179258

What Problem This Solves

Fixes photos disappearing from model context on later text-only turns in Docker-sandboxed conversations, including Telegram photos whose staged copies still exist.

User Impact

Retained images hydrate from the same staged copy on later turns, including affected existing transcripts. History previews retain the original managed URI. Missing copies and paths outside the active sandbox remain unavailable; no configuration changes or migration are required.

Why This Change Was Made

Commit 728d16e (#161842) preserved the original media URI for previews, but transcript serialization omits the runtime staged flag. Replay consequently preferred that URI and searched a different sandbox filename. The current-turn fix in #168537 cannot repair a later turn without current-attempt media.

The canonical media-reference resolver now recognizes the persisted workspaceDir as staging provenance for filesystem paths, matching the existing hasStagedMediaFacts contract. Paths that are themselves media URIs still reach the existing URI parser and validation. This uses metadata already present in affected transcripts rather than adding another stored field or rewriting history. The active sandbox bridge still enforces containment and bounded reads.

Evidence

  • Source/history confirmation on main fc3a42a7eb87a906597187f18db62201020d275b; no live reproduction claimed.
  • Added replays a staged photo on a later sandbox turn: present, missing, and outside-root in stage-sandbox-media.history.test.ts. These compose real staging, transcript serialization, and later-turn hydration with a host-backed sandbox filesystem fixture; only sandbox provisioning is mocked. The original store file remains present, so rejected copies must not fall back to host media.
  • PR CI is the test gate and covers the regression suite, affected sibling tests, typechecks, and repository checks. Local tests and typechecks were intentionally not run. Live Telegram/Gateway/Docker proof was intentionally skipped per maintainer policy.
  • Changed-file oxlint (core config) and oxfmt: passed. Isolated Codex autoreview through P2: scoped-clean, no actionable findings; review assessed source without running tests.
  • Final-head CI regression job on a7fcc948d7da4591ac3ccc7d408ffd5870269745 passed all 14 staging/history tests, including the three new cases (7.18s suite, 9.79s wrapper under Bun), and all 15 remote-workspace attachment tests. Initial CI caught the existing invalid-uri test regressing when a media URI carried workspace metadata; the follow-up preserves URI validation, and that test now passes. Full CI run 39576023477 completed successfully on that exact head; the native CI watcher reported GREEN with superseded checks reconciled.
  • ClawSweeper review of the final head: no actionable code findings. Its live-proof caveat is covered by the maintainer proof policy above.
  • Simplification: one existing resolver expression changed; no new abstraction, schema, or fallback. Exact LOC against main: production +1/-1 (net 0), tests +47/-0, docs +2/-0.

Honor persisted workspace provenance when choosing the local media reference, so later turns hydrate the same staged copy while previews keep the original URI. Sandbox containment and bounded reads remain unchanged.

Fixes #179258. Regression introduced by 728d16e (#161842). Tests and live proof deferred to PR CI per maintainer policy; local changed-file lint and formatting only.
@clawsweeper

clawsweeper Bot commented Oct 21, 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.

@steipete
steipete marked this pull request as ready for review October 21, 2026 09:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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-21T09:56:07.418183Z a7fcc94 New commits
ℹ️ 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime docker Docker and sandbox tooling agents Agent runtime and tooling size: XS labels Oct 21, 2026
A workspace marker identifies staged filesystem copies, not media URI paths. Keep URI inputs on their existing parsing path so remote attachment preparation still rejects malformed inbound references.

Addresses the existing invalid-uri staging regression reported by PR CI run 39574497224. Local changed-file lint and formatting pass; test execution remains delegated to PR CI.
@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. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes later sandbox turns select an image’s persisted staged path while preserving its original preview URI.

Example: A user sends sample.jpg through Telegram, then asks “What color was it?” without uploading it again.

  • Before: Replay selects media://inbound/sample.jpg and omits the image even though media/inbound/openclaw-staged-abc/input-sample.jpg remains available.
  • After: Replay selects the retained staged copy and loads it through the active sandbox filesystem boundary.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful boundary regression coverage; confidence in runtime behavior remains limited to the supplied harness evidence.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its supplied evidence exercises staging-to-replay through an in-process filesystem fixture, while the inspected historical screenshots cover preview rendering rather than this repair.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An image available on its incoming turn disappears from model context on subsequent text-only turns despite its retained sandbox copy.
Reason: The maintainer-authored direction restores expected conversation continuity with a focused shared-owner repair and no new configuration or stored format.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it narrowly repairs a verified persistence-to-replay mismatch that remains on current main, with no actionable correctness finding.

Priority: P2
Reviewed head: a7fcc948d7da4591ac3ccc7d408ffd5870269745

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No current-head Gateway/Telegram/Docker later-turn capture or demonstrated red-on-base run was supplied; the added regression instead exercises real staging, serialization, and hydration with a host-backed bridge.
Agent review details

How this fits together

Inbound attachment staging supplies media facts to transcript persistence; the shared reference resolver later selects sources for image hydration, which validates and reads them through the active sandbox bridge before supplying model input.

flowchart TD
  A[Inbound photo] --> B[Workspace staging]
  B --> C[Persisted transcript]
  C --> D[Media reference resolver]
  D --> E[Sandbox filesystem bridge]
  E --> F[Historical image hydration]
  F --> G[Model context]
Loading

Technical review

Best possible solution:

Use the existing shared resolver and persisted workspace metadata to recover staged images while retaining preview URIs and active sandbox validation.

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

Current-main staging, transcript normalization, reference selection, and sandbox alias validation establish the reported failure path; no target code or tests were executed during this review.

Is this the best way to solve the issue?

This is the smallest complete repair: it recognizes already-persisted staging metadata at the shared selection owner without adding state, rewriting transcripts, or weakening filesystem validation.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Staged reference preference keeps the original intent (5c69645: Prefer a staged sandbox copy over its managed-store alias, including current-turn transcript snapshots captured before staging.)
  • Managed preview URI preservation keeps the original intent (728d16e: Keep history previews fetchable while redacting private workspace paths; the original patch and maintainer landing discussion confirm that intent.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source 0, Tests +47, Docs +2. Total +49 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 47 0 +47
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 50 1 +49

Review metrics

Metric Value Why it matters
Production versus regression code Production +1/-1; tests +47/-0 The production change reuses the existing owner; the test growth covers successful replay and two distinct rejection conditions.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #179258
Summary: This PR directly repairs the historical staging-provenance mismatch documented by the linked issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P2: Historical visual context disappears in sandboxed conversations, while text interaction and the incoming image turn remain available.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Historical visual context disappears in sandboxed conversations, while text interaction and the incoming image turn remain available.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed October 21, 2026, 5:35 AM ET / 09:35 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

PR CI is the proof for this change per maintainer policy. Live Gateway/Telegram/Docker proof and local test/typecheck execution were intentionally skipped.

CI run 39576023477 completed successfully on a7fcc948d7da4591ac3ccc7d408ffd5870269745. The final-head regression job passed all 14 staging/history tests and all 15 remote-workspace attachment tests, including the URI-validation case caught and fixed after the initial run. The native watcher reported GREEN after reconciling superseded checks.

ClawSweeper reported no code findings on this head. Its live-proof note does not require additional proof under this policy. This PR remains open and ready; no merge was performed.

@steipete
steipete merged commit 662e2d3 into main Oct 21, 2026
145 of 147 checks passed
@steipete
steipete deleted the fix/sandbox-history-media-staged-provenance branch October 21, 2026 09:47
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 22, 2026
* fix: retain staged photos in sandbox conversation history

Honor persisted workspace provenance when choosing the local media reference, so later turns hydrate the same staged copy while previews keep the original URI. Sandbox containment and bounded reads remain unchanged.

Fixes openclaw#179258. Regression introduced by 2a7d513 (openclaw#161842). Tests and live proof deferred to PR CI per maintainer policy; local changed-file lint and formatting only.

* fix: preserve validation for workspace media URI inputs

A workspace marker identifies staged filesystem copies, not media URI paths. Keep URI inputs on their existing parsing path so remote attachment preparation still rejects malformed inbound references.

Addresses the existing invalid-uri staging regression reported by PR CI run 39574497224. Local changed-file lint and formatting pass; test execution remains delegated to PR CI.
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
Keep temporary channel-image read failures on the current run rather than persisting permanent hydration suppression. Reconcile run-only skips with recorded attachments through one shared source-and-occurrence matcher for prompt hydration, workers, and image-input detection.

Both admission-mode regressions fail on the base; 170 focused tests pass with the fix. Preserve intentional suppression and leave ambiguous historical records unchanged. Exact-head CI passes.

Co-authored-by: Masato Hoshino <[email protected]>

(cherry picked from commit 15a5706)

Release adaptation: baseline images.ts lacks applySandboxStagedImagePaths (#179301), so the recorded-fact suppression is applied directly to normalizeMediaFacts and the main-only staged-copy media-refs case is not ported. Baseline attempt-session-prepare still attaches persisted facts as runtime prompt facts, so those now go through applyRunHydrationSuppression with the attempt media to keep this run skipping the unreadable image. The collect-queue case is ported into the baseline enqueue/scheduleFollowupDrain test style.
yehezkel-assistant Bot pushed a commit to razshlomo/openclaw that referenced this pull request Oct 30, 2026
…porary, openclaw#179258)

On later turns the loader followed the media://inbound alias to
media/inbound/<id> inside the sandbox, where no copy exists; the staged copy
lives under media/inbound/openclaw-staged-<uuid>/. The photo dropped out of
model context after its first model call ("Sandbox media reference is not
staged"). Seen on the motivator group agent since 2026-10-26.

Port of openclaw#179301 (merged to main 2026-10-21); 10.7 lacks the
`fact.staged && fact.path` branch that the upstream diff edits, so the
condition is applied to the bare alias lookup.

TEMPORARY: remove once we run a release containing openclaw#179301
(not in v2026.10.9 or v2026.10.10-beta.5). Running as a dist patch on
2026.10.7 since 2026-10-30.
tomperi pushed a commit to tomperi/openclaw that referenced this pull request Nov 11, 2026
* fix: retain staged photos in sandbox conversation history

Honor persisted workspace provenance when choosing the local media reference, so later turns hydrate the same staged copy while previews keep the original URI. Sandbox containment and bounded reads remain unchanged.

Fixes openclaw#179258. Regression introduced by 728d16e (openclaw#161842). Tests and live proof deferred to PR CI per maintainer policy; local changed-file lint and formatting only.

* fix: preserve validation for workspace media URI inputs

A workspace marker identifies staged filesystem copies, not media URI paths. Keep URI inputs on their existing parsing path so remote attachment preparation still rejects malformed inbound references.

Addresses the existing invalid-uri staging regression reported by PR CI run 39574497224. Local changed-file lint and formatting pass; test execution remains delegated to PR CI.

(cherry picked from commit 662e2d3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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.

[Bug]: Telegram photos disappear from Docker sandbox model context on later turns (persisted media loses staged provenance)

1 participant