Skip to content

fix: keep initial attachments available in new worktrees - #186572

Merged
shakkernerd merged 1 commit into
mainfrom
initial-attachment-worktree-handoff
Oct 28, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
initial-attachment-worktree-handoff

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A file attached to the first message of a new worktree session can be saved successfully but unavailable to the agent. Attachment preparation copies it into the session's initial sandbox before the deferred worktree exists. The agent later receives that relative path in a different workspace, so an ordinary task can fail and ask for the file again even though the saved attachment still downloads correctly.

User Impact

Initial file attachments remain usable when the accepted turn moves into its newly prepared worktree. Users can start work from the uploaded file without reattaching it. Existing-worktree uploads retain their normal staging path, and upload validation, cancellation, managed-PDF fallback, and permission checks remain in their existing owners. This requires no configuration or stored-data migration.

Why This Change Was Made

The attachment producer was treating a successful copy into an interim sandbox as proof that the file had been staged for execution. Reply preparation intentionally trusts that proof and avoids another copy. Deferred workspace preparation changes the destination after the first copy, invalidating that assumption.

While workspace selection remains pending, attachment preparation now keeps the managed original as the runtime source instead of publishing the interim directory as final staging proof. It still completes its existing pre-acceptance staging checks and error classification. The normal reply staging path then copies the original into the bound workspace. The admission snapshot uses its internal session type so the producer can consume the existing pending-workspace facts without casts or new state.

Evidence

The focused regression uses the registered session-creation and chat handlers with the real attachment parser, sandbox staging, deferred worktree preparation, and reply preparation. Only model execution is replaced by an observer. It reads the advertised attachment path from the actual final workspace and compares the bytes with the uploaded input.

On the unchanged base, the initial-turn case fails with ENOENT in the new worktree projection; the existing-worktree follow-up reads the expected bytes. On this patch, both cases read the expected bytes. Changed-file formatting/lint, selected type checks, and the related admission, cancellation, PDF fallback, SSH staging, and prompt-stability tests pass. Automated source review covering P0–P3 reported no actionable findings. The live guest flow on c1d0ecba1001 submitted the original 184,251-byte ZIP once with New worktree. The agent read and extracted the exact uploaded bytes from the mounted worktree projection and completed an offline order explorer without reattachment. Independent runtime readback matched the managed original, worktree and execution projection. The saved HTML opened through Files; filtering a duplicate order and opening its original CSV source line worked. Final process receipts passed and preserved the archive and all 77 handoff files.

Independent engineering review is clean, and exact-head hosted CI passed. The before/after evidence uses the same archive, guest permissions, project fixture, execution image and viewport; fresh session/worktree identities intentionally differ. Recording speed changes are labeled and do not measure latency.

Visual evidence

Open preview

Before After
Saved initial ZIP is visible, but the new-worktree agent reports the path missing and asks for reattachment. The same initial ZIP workflow completes an offline order explorer and preserves the source data.

Real initial upload, completed task, and saved explorer interaction; speed changes are labeled.

proof.mp4

Visual verification

  • Baseline: f76e79b
  • Exact head: c1d0ecba10012cb1552f767006a2475bd9fce216
  • Scenario: Create a guest project session with New worktree and one initial ZIP, then inspect the generated order explorer without reattaching the archive.
  • Runtime/build: OpenClaw 2026.10.8-c1d0ecba1001-2026-10-28T05-55-23.404Z; actual guest Docker image sha256:2023bd0cdcb933f6721e42ce18563a0d289749c26b59e1b59eb04ffb0adeacc9
  • Upload: 184,251 bytes; SHA-256 c93ff0bd3a8aa4bdda37d997ec3c00591cda7191aec28e74a2a5c6575a78c3b9
  • Submission: One sessions.create with worktree=true and ZIP; no chat.send or reattachment.
  • Execution: Native agent read and ZIP extraction succeeded in the mounted new-worktree projection; exact input hash preserved.
  • Useful output: Saved HTML opens through Files. MAR-DUP search returns one of 23 order IDs, two original rows and one revised row; source line 17 matches the archived CSV.
  • Own current-source regression fails before the fix and passes with the fix; existing-worktree follow-up remains readable.
  • Same archive, guest permissions, project fixture, qualified execution image, 1440×1000 viewport and light theme. Fresh session/worktree identities differ intentionally to exercise initial creation; final content differs because the task can now complete.
  • Independent native metadata/readback joins managed original, worktree, actual mounted projection and exact running build.
  • Recorded processes completed with exit code 0 and preserved archive/handoff hashes; no active or queued work remains.
  • Captioned recording retains the actual trigger and final explorer/source interaction; accelerated intervals are labeled and are not latency measurements.

@shakkernerd shakkernerd self-assigned this Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 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 gateway Gateway runtime size: S labels Oct 28, 2026
@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserve managed attachment originals until deferred workspace preparation selects the new session’s final worktree.

Example: Attach the 184,251-byte Sales review – March 2026.zip when creating a session with New worktree.

  • Before: The saved ZIP downloads, but the agent receives a path missing from its execution workspace and requests reattachment.
  • After: The agent reads and extracts the initial ZIP in its new workspace and completes the order explorer without reattachment.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused repair with meaningful final-workspace byte checks, supplied live evidence, and passing exact-head gates; the recording could not be inspected in this review environment.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): Inspected before/after screenshots and the exact-head live guest record cover an initial ZIP submitted through session creation with New worktree, followed by successful agent extraction and task completion without reattachment; this addresses the prior rank-up request.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An uploaded file is saved successfully but unavailable to the agent when the first turn moves into a new worktree.
Reason: Restores expected attachment usability with a narrow change; maintainer authorship establishes direction, and every hunk supports the same repair.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current attachment handoff bug with a focused change, useful regression coverage, and supplied live evidence; no actionable defects remain.

Priority: P2
Reviewed head: c1d0ecba10012cb1552f767006a2475bd9fce216

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway attachment preparation validates uploads before acceptance; deferred session preparation then binds the execution workspace, where reply preparation stages the managed originals for the agent.

flowchart TD
  A[Initial session upload] --> B[Managed attachment store]
  B --> C[Preacceptance staging validation]
  C --> D[Deferred worktree preparation]
  D --> E[Reply attachment staging]
  B --> E
  E --> F[Agent execution workspace]
Loading

Technical review

Best possible solution:

Land the focused producer fix so staging proof describes the final execution workspace.

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

Current main publishes interim workspace metadata that suppresses final staging; the supplied baseline screenshot and recorded base-failing regression match that path, though this review ran no target code.

Is this the best way to solve the issue?

The patch repairs the attachment producer using existing pending-workspace facts and the existing reply staging owner, without introducing another state or policy layer.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Admission snapshot typing keeps the original intent (0474704: Goal admission reused existing session and run admission machinery; the internal snapshot type exposes existing pending-workspace facts without changing runtime state.)
  • Attachment staging and managed originals keeps the original intent (af75a8d: SSH staging retained canonical managed originals while preserving session-specific sandbox identity and source validation.)
  • Caller-owned preacceptance staging changes intended behavior with a stated reason (ff9c932: Keep attachment staging in its existing caller and preserve behavior; this patch explains why an interim copy cannot certify the later execution destination.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +11, Tests +108. Total +119 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 14 3 +11
Tests 1 108 0 +108
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 122 3 +119

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Initial attachments can become unreadable in new worktree sessions, disrupting the task while leaving the managed original available.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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 (1 earlier review cycle)
  • reviewed 2026-10-28T06:08:00.776Z sha c1d0ecb :: needs maintainer review before merge. :: none

Reviewed October 28, 2026, 2:57 AM ET / 06:57 UTC (Revision 2).

@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 28, 2026
@shakkernerd
shakkernerd merged commit 62177f2 into main Oct 28, 2026
155 checks passed
@shakkernerd
shakkernerd deleted the initial-attachment-worktree-handoff branch October 28, 2026 07:10
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Initial uploads remain readable when a session starts in a new worktree.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
…6572)

Initial file attachments remain available after deferred worktree preparation, while preserving pre-acceptance validation and existing attachment paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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