Skip to content

fix: prevent duplicate and lost agent delivery - #120108

Merged
steipete merged 1 commit into
mainfrom
steipete/sub-agent-recovery-and-delivery-bugs-7d9706
Aug 7, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/sub-agent-recovery-and-delivery-bugs-7d9706

Conversation

@steipete

@steipete steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes three delivery failures found in production: synthetic sub-agent and lifecycle turns could invalidate an existing Claude CLI session and reseed it from a lossy text-only transcript; message-tool sends and polls could discard their host-generated idempotency key before reaching the Gateway; and failed-session recovery notices could bypass normal outbound delivery and disappear on Signal and other plugins that intentionally do not implement send as a message action.

Why This Change Was Made

Synthetic turns now keep their turn-local reply policy separate from the existing session's stable CLI binding policy. Core outbound send and poll paths carry the host-owned idempotency key end to end. Main-session recovery notices now use a typed Gateway-owned normal outbound path with durable delivery identity, no plugin action fallback, and no transcript mirroring into a rebound session.

The reported openclaw models list Sonnet 5 crash was also checked and is already fixed on main by #102186; this PR does not change model code.

AI-assisted: implementation and review used Codex and Claude Code; the final diff was manually inspected and source-aware autoreview found no actionable issue.

User Impact

Sub-agent completions and internal lifecycle turns no longer force unnecessary Claude CLI reseeds or invite repeated agent actions from reconstructed history. Retried gateway-mode sends retain the same logical delivery identity, and operators on Signal and other outbound-only plugins receive the visible notice when a main session cannot be resumed after restart.

Evidence

  • node scripts/run-vitest.mjs src/auto-reply/reply/source-reply-delivery-mode.test.ts src/commands/agent.test.ts src/agents/main-session-restart-recovery.test.ts src/gateway/server-instance-runtime.test.ts src/infra/outbound/message-action-runner.media.test.ts src/infra/outbound/message-action-runner.poll.test.ts src/infra/outbound/message.channels.test.ts src/infra/outbound/outbound-send-service.test.ts src/agents/tools/message-tool.test.ts — 9 files / 563 tests passed across 6 shards.
  • Exact behavior filters passed for stable synthetic CLI binding facts, send/poll idempotency propagation, successful/parallel identical-send separation, Signal-shaped normal outbound recovery, failure-before-send ordering, and canonical recovery routing.
  • pnpm tsgo — passed.
  • pnpm check:test-types — passed.
  • targeted node scripts/run-oxlint.mjs ... for all changed files — passed.
  • pnpm build — passed, including CLI import guard and plugin SDK export checks.
  • git diff --check — passed.
  • Codex autoreview (gpt-5.6-sol, high) — clean, no accepted/actionable findings.
  • Blacksmith Testbox was unavailable locally because the blacksmith executable was absent; repository policy fallback was the successful local heavy gate above. Exact-head hosted CI remains required before landing.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 7, 2026
@steipete
steipete marked this pull request as ready for review August 7, 2026 02:12
@steipete

steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready verification for exact head 1dbc6d2f7ae160a6afc799b21c54fb29080d8413:

  • Focused regression suite: node scripts/run-vitest.mjs across the 9 changed behavior suites — 563 tests passed across 6 shards.
  • Exact behavior probes passed for synthetic CLI binding stability, send/poll idempotency propagation, identical-send separation, Signal-shaped normal outbound recovery, and failure-before-send ordering.
  • pnpm tsgo passed.
  • pnpm check:test-types passed.
  • Targeted node scripts/run-oxlint.mjs ... passed for every changed file.
  • pnpm build passed, including CLI bootstrap import and plugin SDK export guards.
  • git diff --check passed.
  • Final Codex autoreview (gpt-5.6-sol, high) was clean with no accepted/actionable findings.
  • Exact-head hosted CI run 31140475412 is green.

Proof gap: Blacksmith Testbox could not start because the local blacksmith executable is unavailable, so repository-policy local fallback supplied the heavy type/lint/build proof above. ClawSweeper's initial review and one explicitly requested exact-head re-review both remained start placeholders through lease expiry; neither produced a verdict or any Rank-up moves: to apply. I am recording that automation gap explicitly rather than treating the placeholder as a completed review.

@steipete
steipete merged commit 47640e0 into main Aug 7, 2026
184 checks passed
@steipete
steipete deleted the steipete/sub-agent-recovery-and-delivery-bugs-7d9706 branch August 7, 2026 03:30
@steipete

steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to VACInc/openclaw that referenced this pull request Aug 7, 2026
* origin/main:
  refactor(test): compress repetitive fixtures in mega-tests, batch 2 (openclaw#120124)
  refactor(ui): adopt shared chat-host fixture across chat suites (openclaw#120120)
  fix(ci): provision native Android resources for frozen current-contract targets (openclaw#120081)
  fix: preserve agent delivery identity (openclaw#120108)
  fix(qqbot): add cause-specific setup guidance (openclaw#119780)
  fix(venice): replay Gemini tool signatures by turn occurrence (openclaw#119783)
  fix(gateway): yield before TTS status diagnostics (openclaw#119788)
  fix: gateway restart fails and leaves the macOS LaunchAgent unloaded when the gateway drains active work (openclaw#116875)
  fix(clickclack): show native agent progress while replying (openclaw#116683)
  fix: unhandled rejection crashes process when raw stream write fails (openclaw#119400)
  fix: prevent duplicate outbound delivery during concurrent recovery (openclaw#119966)

# Conflicts:
#	src/agents/embedded-agent-runner/run.incomplete-turn.test.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant