Skip to content

fix(compaction): skip replay-unsafe session sends#93293

Merged
steipete merged 13 commits into
openclaw:mainfrom
mushuiyu886:feat/issue-84139
Jul 16, 2026
Merged

fix(compaction): skip replay-unsafe session sends#93293
steipete merged 13 commits into
openclaw:mainfrom
mushuiyu886:feat/issue-84139

Conversation

@mushuiyu886

@mushuiyu886 mushuiyu886 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #84139.

Summary

  • Filters only the completed active target-side sessions_send tail from compaction branch fallback. Historical turns and unfinished turns ending in tool calls/results remain recoverable.
  • Converts source-side sessions_send calls into inert summary text, preserving call IDs, arguments, returned results, failures, empty results, and missing-result state without leaving executable tool-call blocks to replay.
  • Recognizes provider-prefixed tool names and keeps ordinary compaction fallback unchanged.

Root cause

When normal compaction preparation contained no real conversation, the safeguard reused the session branch verbatim. That could replay an already-delivered target-side inter-session turn or an already-executed source-side sessions_send call. The previous candidate filter was too broad: it also removed historical and unfinished work.

The repaired patch stays at the compaction fallback owner boundary. It drops a target-side turn only when the original branch ends in terminal assistant text. Source-side send calls/results become inert evidence instead of executable tool history.

Compatibility and scope

  • No public API, config, schema, protocol, persistence, provider-routing, or delivery-execution changes.
  • No normal compaction behavior change when branch fallback is not needed.
  • Root CHANGELOG.md remains release-owned; this PR body carries release-note context.

Merge risk

  • merge-risk: session-state: over-filtering could lose recovery context.
  • merge-risk: message-delivery: under-filtering could replay a side effect.

The focused tests cover completed target turns, historical target turns, ordinary and nested unfinished tool work, resolved/failed/missing source-side sends, namespaced tool names, and normal fallback preservation.

Proof

Rebased current head: e9dafd53382c7abc45d285dddf98d882abf85f33

Blacksmith Testbox run: https://github.com/openclaw/openclaw/actions/runs/29480862149

oxfmt --check (2 changed files): passed
plugin-sdk boundary DTS and targeted oxlint: passed
src/agents/agent-hooks/compaction-safeguard.test.ts: 111 passed
git diff --check: passed
fresh aggregate autoreview: no accepted/actionable findings

Behavior verification remains source-level and focused rather than a live timing capture across two running agents. The linked intermittent path is therefore partially, not fully, reproduced end to end.

Contributor credit

Original fix and regression direction by @mushuiyu886. Maintainer repair commits retain Co-authored-by: 杨浩宇0668001029 <[email protected]>.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 10:30 PM ET / 02:30 UTC.

Summary
The branch filters replay-unsafe sessions_send and messaging-send artifacts from compaction-safeguard branch fallback while preserving safe assistant text, with regression coverage for target-side, source-side, and mixed-content fallback cases.

PR surface: Source +112, Tests +237. Total +349 across 2 files.

Reproducibility: yes. at the source level, but not as a live timing repro in this review. Current main still falls back to unfiltered branch messages, sessions_send records matching inter-session provenance, and the PR adds targeted regressions for the unsafe replay shapes.

Review metrics: 1 noteworthy metric.

  • Fallback replay cases covered: 3 regression scenarios added. The tests cover target-side inter-session turns, source-side send tool artifacts, and mixed assistant text preservation at the changed fallback boundary.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #84139
Summary: This PR is the focused candidate fix for the canonical compaction-safeguard sessions_send fallback replay issue; nearby A2A duplicate-message PRs are adjacent but do not supersede this branch.

Members:

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

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

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

Risk before merge

  • [P2] The change intentionally alters which recovered branch entries can become compaction summary input; under-filtering could replay already-executed send artifacts, while over-filtering could lose safe fallback context.
  • [P1] The PR head is behind current main, so maintainers should refresh/recheck the merge result before landing even though the stale-base drift alone is not a patch defect.
  • [P1] The contributor proof exercises the production hook path with terminal output and tests, but it does not include a full live two-agent timing capture of the intermittent duplicate-delivery scenario.

Maintainer options:

  1. Refresh and land the focused filter (recommended)
    After rebasing or otherwise proving the exact merge head, proceed with the compaction-boundary filter because the source path and regression tests cover the reported replay mode.
  2. Require a live timing capture
    Maintainers can ask for a full two-agent compaction timing proof before merge if terminal production-hook proof is not enough for this risk level.
  3. Pause for a broader A2A design
    Pause this PR only if maintainers decide the fallback filter should be replaced by a broader delivery/API ownership change instead of a narrow compaction repair.

Next step before merge

  • No ClawSweeper repair job is needed because no concrete patch defect was found; the remaining action is maintainer review, stale-base refresh, and normal landing gates.

Security
Cleared: The diff touches only agent compaction runtime logic and colocated tests; I found no concrete security or supply-chain regression.

Review details

Best possible solution:

Land this focused compaction fallback filter after refreshing the merge result and exact-head gates, while leaving the adjacent A2A reverse-send and message-tool mirror duplicate paths to their separate PRs.

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

Yes at the source level, but not as a live timing repro in this review. Current main still falls back to unfiltered branch messages, sessions_send records matching inter-session provenance, and the PR adds targeted regressions for the unsafe replay shapes.

Is this the best way to solve the issue?

Yes. The compaction safeguard fallback is the narrow owner boundary for this bug because it is the point where current main reuses recovered branch messages for summarization; the related A2A API/delivery PRs address adjacent duplicate modes rather than this fallback replay.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal proof over the production compaction safeguard hook path plus focused tests, lint, and diff checks; a live two-agent timing capture would be stronger but is not required for this nonvisual runtime path.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-fix terminal proof over the production compaction safeguard hook path plus focused tests, lint, and diff checks; a live two-agent timing capture would be stronger but is not required for this nonvisual runtime path.

Label justifications:

  • P2: This is a focused fix for an intermittent duplicate-delivery/session-compaction bug with real but limited blast radius.
  • merge-risk: 🚨 session-state: The PR changes recovered session-branch content used for compaction summaries when normal preparation omitted real conversation content.
  • merge-risk: 🚨 message-delivery: The same boundary must avoid replaying already-executed sessions_send artifacts without suppressing safe conversation context.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-fix terminal proof over the production compaction safeguard hook path plus focused tests, lint, and diff checks; a live two-agent timing capture would be stronger but is not required for this nonvisual runtime path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal proof over the production compaction safeguard hook path plus focused tests, lint, and diff checks; a live two-agent timing capture would be stronger but is not required for this nonvisual runtime path.
Evidence reviewed

PR surface:

Source +112, Tests +237. Total +349 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 114 2 +112
Tests 1 237 0 +237
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 351 2 +349

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the inter-session input provenance work and much of the earlier sessions_send delivery semantics that this filter relies on. (role: feature owner / adjacent owner; confidence: high; commits: 85409e401b65, a25922a21f86; files: src/agents/tools/sessions-send-tool.ts, src/sessions/input-provenance.ts)
  • vincentkoc: Vincent Koc recently touched sessions_send explicit keys, delivery evidence, and nearby agent hook/runtime surfaces. (role: recent area contributor; confidence: high; commits: 3659ff8bbf71, 0ea08076c3b5, 6cb631afc9c5; files: src/agents/tools/sessions-send-tool.ts, src/agents/embedded-agent-messaging.ts, src/agents/agent-hooks/compaction-safeguard.ts)
  • Takhoffman: Tak Hoffman authored adjacent sessions_send stale-reply carryover work in the same delivery-fallback problem family. (role: adjacent sessions_send contributor; confidence: medium; commits: 5b4669632a9d; files: src/agents/tools/sessions-send-tool.ts)
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-06-29T08:18:17.433Z sha 69fa892 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-07T01:48:55.680Z sha 69fa892 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 15, 2026
@mushuiyu886

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 15, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 18, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Jun 18, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 18, 2026
@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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 18, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 7, 2026
@steipete steipete self-assigned this Jul 16, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: L triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed size: M labels Jul 16, 2026
@steipete
steipete merged commit f771aa5 into openclaw:main Jul 16, 2026
134 of 140 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
* fix(compaction): skip replay-unsafe session sends

* fix(compaction): preserve safe text around session sends

* fix(compaction): narrow replay filtering to sessions_send

Co-authored-by: 杨浩宇0668001029 <[email protected]>

* test(compaction): use review-safe key fixtures

Co-authored-by: 杨浩宇0668001029 <[email protected]>

* test(compaction): use placeholder API key

Co-authored-by: 杨浩宇0668001029 <[email protected]>

* test(compaction): limit fixture cleanup to new cases

Co-authored-by: 杨浩宇0668001029 <[email protected]>

* fix(compaction): preserve completed sessions_send history

Co-authored-by: 杨浩宇0668001029 <[email protected]>

* fix(compaction): preserve unfinished delegated work

Co-authored-by: 杨浩宇0668001029 <[email protected]>

* fix(compaction): detect completion before replay filtering

Co-authored-by: 杨浩宇0668001029 <[email protected]>

* fix(compaction): retain unresolved send status

Co-authored-by: 杨浩宇0668001029 <[email protected]>

* fix(compaction): preserve inert send outcomes

Co-authored-by: 杨浩宇0668001029 <[email protected]>

* fix(compaction): narrow terminal tail type

Co-authored-by: 杨浩宇0668001029 <[email protected]>

* fix(compaction): guard replay input lookup

Co-authored-by: 杨浩宇0668001029 <[email protected]>

---------

Co-authored-by: Peter Steinberger <[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 merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2026.5.18] Compaction safeguard causes duplicate messages on sessions_send interactions

3 participants