Skip to content

fix(agents): preserve media side merges during prompt release#100490

Merged
steipete merged 3 commits into
mainfrom
codex/prompt-release-side-merges
Jul 6, 2026
Merged

fix(agents): preserve media side merges during prompt release#100490
steipete merged 3 commits into
mainfrom
codex/prompt-release-side-merges

Conversation

@steipete

@steipete steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Users sending multiple visible media replies while an embedded prompt lock is released could receive the media and then see the run fail with session file changed while embedded prompt lock was released.

This replaces #100033 with a current-main, maintainer-owned branch because the contributor fork could not be updated without retaining stale ancestry.

Why This Change Was Made

Delivery mirrors append a side branch containing messages plus leaf controls. Prompt-release recovery previously classified the messages but treated every leaf control as an ownership takeover.

The new path accepts only side-mode leaf controls whose target remains the active leaf and whose append cursor matches the current side branch. Validation happens before mutation; active-branch changes, cursor resets, malformed records, and non-side controls still trigger takeover recovery.

User Impact

Batched media replies can finish without a false post-delivery failure. The session ownership fence remains fail-closed for prompt-affecting changes.

Evidence

  • Blacksmith Testbox: 163 focused tests passed across attempt.session-lock.test.ts and session-manager.test.ts.
  • Blacksmith Testbox: formatting passed for all five touched files.
  • Fresh branch autoreview: clean, confidence 0.94; no accepted/actionable findings.
  • Original contributor live proof: 11 Weixin image deliveries completed while prompt-released transcript changes merged; the run ended successfully with no new takeover error.
  • git diff --check passed.

Co-authored with @scotthuang; contributor commits and changelog attribution are preserved.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Jul 5, 2026
@steipete
steipete force-pushed the codex/prompt-release-side-merges branch from d9fb2ce to a1f920d Compare July 5, 2026 23:17
@clawsweeper

clawsweeper Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed July 5, 2026, 8:18 PM ET / 00:18 UTC.

Summary
The branch adds prompt-release side-leaf classification, SessionManager active-leaf preservation validation, focused regressions, and a CHANGELOG entry for media delivery side merges.

PR surface: Source +62, Tests +256, Docs +1. Total +319 across 5 files.

Reproducibility: yes. source-reproducible: current main accepts delivery mirror message rows but does not classify ordinary side leaf controls in the normal prompt-release path. I did not rerun the live Weixin flow, but the PR and source PR include after-fix logs showing 11 media deliveries completed without the takeover error.

Review metrics: 1 noteworthy metric.

  • Session-state boundary change: 1 guarded side-leaf exception added. Maintainers should notice that prompt-released side leaf controls can now merge instead of always triggering takeover recovery.

Stored data model
Persistent data-model change detected: serialized state: src/agents/embedded-agent-runner/run/attempt.session-lock.ts, serialized state: src/agents/sessions/session-manager.test.ts, serialized state: src/agents/sessions/session-manager.ts, unknown-data-model-change: src/agents/sessions/session-manager.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: canonical
Canonical: #100490
Summary: This PR is the narrow current-main replacement for the same media-delivery prompt-lock bug attempted in the broad conflicting source branch.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Remove the direct CHANGELOG.md entry.
  • Wait for the remaining exact-head CI jobs to complete.
  • Get maintainer acceptance of the guarded session-state boundary.

Risk before merge

  • [P1] The PR intentionally admits one unowned prompt-released side leaf-control shape; a maintainer should accept that active-leaf plus side-cursor checks are the intended session ownership fence.
  • [P1] At inspection, two exact-head CI jobs were still in progress, so landing should wait for the final check state even though this is not a diff-specific automation risk.

Maintainer options:

  1. Accept the guarded side-leaf boundary (recommended)
    Merge after cleanup and checks if maintainers agree the active-leaf plus side-cursor guard is the intended session-state fence.
  2. Strengthen the side-leaf contract
    Ask for a narrower delivery-mirror invariant or additional guard coverage before merging the side-leaf exception.
  3. Pause and keep takeover fail-closed
    Leave the PR unmerged if preserving the existing fail-closed behavior is preferable to this bounded media-delivery fix.

Next step before merge

  • [P2] A repair worker can safely remove only the direct CHANGELOG entry; the session-state boundary itself still needs maintainer review before merge.

Maintainer decision needed

  • Question: Should this PR accept active-leaf-preserving prompt-released side leaf controls as the session ownership boundary for media delivery mirrors?
  • Rationale: The code fix is narrow, but it deliberately changes when unowned prompt-released leaf controls are merged instead of treated as takeover, which is a session-state boundary choice automation should not approve alone.
  • Likely owner: steipete — He owns the replacement branch and posted the maintainer-facing land-ready summary for this boundary decision.
  • Options:
    • Accept Guarded Boundary (recommended): Merge after the changelog cleanup and final checks if maintainers agree the active leaf and append-cursor checks are the right ownership fence.
    • Tighten Before Merge: Require a stricter delivery-mirror contract or more guard coverage before admitting the side-leaf exception.
    • Keep Fail-Closed Behavior: Pause or close the PR if maintainers prefer the current false takeover failure over accepting any unowned leaf-control merge path.

Security
Cleared: The diff does not change dependencies, workflows, secrets, permissions, downloaded artifacts, or package execution surfaces; the security-sensitive concern is session-state correctness, covered as merge risk.

Review findings

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:25
Review details

Best possible solution:

Merge the narrow session-state fix after removing the direct CHANGELOG entry, exact-head checks finish, and maintainers accept the guarded side-leaf boundary.

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

Yes, source-reproducible: current main accepts delivery mirror message rows but does not classify ordinary side leaf controls in the normal prompt-release path. I did not rerun the live Weixin flow, but the PR and source PR include after-fix logs showing 11 media deliveries completed without the takeover error.

Is this the best way to solve the issue?

Mostly yes: the classifier plus SessionManager pre-mutation guard is the narrow owner-boundary fix for the observed false takeover. The direct CHANGELOG edit should be removed because release notes already belong in the PR body or squash metadata.

Full review comments:

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:25
    This prior ClawSweeper finding is still present at the current head. CHANGELOG.md is release-owned for normal PRs, and the release-note context already lives in the PR body, so this line should not be carried in the branch.
    Confidence: 0.92

Overall correctness: patch is correct
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a focused user-visible media-delivery bugfix with limited blast radius and normal maintainer review urgency.
  • merge-risk: 🚨 session-state: The diff changes which prompt-released leaf controls may update preserved session side-branch state instead of triggering takeover recovery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body and related source PR provide redacted live-log proof: 11 Weixin media deliveries merged during prompt release and the embedded run completed without the takeover error.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and related source PR provide redacted live-log proof: 11 Weixin media deliveries merged during prompt release and the embedded run completed without the takeover error.
Evidence reviewed

PR surface:

Source +62, Tests +256, Docs +1. Total +319 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 63 1 +62
Tests 2 256 0 +256
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 320 1 +319

Acceptance criteria:

  • [P1] git diff --check.

What I checked:

Likely related people:

  • steipete: He authored the narrow replacement branch, posted the land-ready proof summary, and the PR carries the maintainer label for this session-state boundary review. (role: replacement branch owner and likely follow-up owner; confidence: high; commits: 10bf3475ab90, 766166bcc2d9; files: src/agents/embedded-agent-runner/run/attempt.session-lock.ts, src/agents/sessions/session-manager.ts, src/agents/sessions/session-manager.test.ts)
  • scotthuang: He opened the related source PR for the same media prompt-lock failure, is credited as co-author on this replacement, and provided the live Weixin media-delivery proof reused here. (role: source fix author and proof provider; confidence: high; commits: ed896d51ad5d, 10bf3475ab90, 766166bcc2d9; files: src/agents/embedded-agent-runner/run/attempt.session-lock.ts, src/agents/sessions/session-manager.ts, src/agents/sessions/session-manager.test.ts)
  • tianxiaochannel-oss88: He authored most commits in the merged prompt-release session-lock ownership PR that established the surrounding owned-write fence behavior this PR extends. (role: adjacent session-lock feature contributor; confidence: medium; commits: 3b630cdb7884, ff3066ef533e, 02cad4a33a6d; files: src/agents/embedded-agent-runner/run/attempt.session-lock.ts)
  • jalehman: He merged the prior prompt-release session-lock PR and authored the embedded session-lock reacquire commit in that area. (role: adjacent merger and contributor; confidence: medium; commits: 0e709a305770, 33f88febc322; files: src/agents/embedded-agent-runner/run/attempt.session-lock.ts, CHANGELOG.md)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (2 earlier review cycles)
  • reviewed 2026-07-05T23:27:38.877Z sha a1f920d :: found issues before merge. :: [P3] Remove the release-owned changelog edit
  • reviewed 2026-07-05T23:49:02.135Z sha ed953e3 :: found issues before merge. :: [P3] Remove the release-owned changelog entry

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 5, 2026
@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready at exact head 8b466cb84fe8b49135cd37608c634c9c9d3237f9.

The final implementation admits prompt-released delivery side leaves only when the active leaf and current side cursor remain unchanged. SessionManager validates the full batch before mutation; active-branch changes, explicit cursor resets, malformed records, non-side controls, and duplicate ids continue through takeover recovery.

Proof:

  • Blacksmith Testbox: 163 focused cases passed (111 prompt-lock recovery, 52 SessionManager);
  • remote formatting passed for all five touched files;
  • original live proof: 11 Weixin images delivered, prompt-released transcript changes merged, and the embedded run completed without a new takeover error;
  • fresh rebased-tree autoreview: clean, confidence 0.90;
  • native review artifacts: validated, zero findings;
  • exact-head hosted CI: green.

This is the current-main replacement for #100033; @scotthuang's co-authorship is preserved. The release-note credit is deferred to the grouped maintainer changelog after code landing to avoid repeated merge starvation from unrelated concurrent changelog updates.

@steipete
steipete force-pushed the codex/prompt-release-side-merges branch from a1f920d to 8c54821 Compare July 5, 2026 23:31

@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: 8c54821602

ℹ️ 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 thread CHANGELOG.md Outdated
### Fixes

- **Remote browser reliability:** bound persistent Playwright tab enumeration by the existing remote CDP timeout budget and retire timed-out connection attempts so late completions cannot restore a stuck connection. (#80147, #58968) Thanks @HemantSudarshan and @KeaneYan.
- **Prompt-release media delivery:** accept active-leaf-preserving side-append controls while an embedded run temporarily releases its session lock, so successive message-tool media replies merge without a false session-takeover failure. (#100033) Thanks @scotthuang.

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 Remove the manual changelog entry

This normal fix edits CHANGELOG.md, but the root AGENTS.md says CHANGELOG.md is release-only and normal fixes should keep release-note context in the PR body, squash message, or direct commit instead. Leaving this in Unreleased can make the release generator duplicate or stale the note, so this entry should be removed from the commit.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the codex/prompt-release-side-merges branch 3 times, most recently from 4afa7b6 to 766166b Compare July 6, 2026 00:08
@steipete
steipete force-pushed the codex/prompt-release-side-merges branch from 766166b to 8b466cb Compare July 6, 2026 01:25
@steipete
steipete merged commit a1f4aa4 into main Jul 6, 2026
97 checks passed
@steipete
steipete deleted the codex/prompt-release-side-merges branch July 6, 2026 01:37
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 6, 2026
…aw#100490)

* fix(agents): preserve active leaf during side merges

Co-authored-by: scotthuang <[email protected]>

* fix(agents): validate explicit side-branch cursors

Co-authored-by: scotthuang <[email protected]>

* chore: defer prompt-release media changelog

---------

Co-authored-by: scotthuang <[email protected]>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
…aw#100490)

* fix(agents): preserve active leaf during side merges

Co-authored-by: scotthuang <[email protected]>

* fix(agents): validate explicit side-branch cursors

Co-authored-by: scotthuang <[email protected]>

* chore: defer prompt-release media changelog

---------

Co-authored-by: scotthuang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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