Skip to content

fix(agents): treat observed CLI activity as replay-unsafe for whole-turn retries - #122153

Merged
steipete merged 1 commit into
mainfrom
steipete/failover-b2-replay-safety
Aug 11, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/failover-b2-replay-safety

Conversation

@steipete

@steipete steipete commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a CLI-backed agent turn that timed out after observable activity could be replayed automatically when no execution phase mark arrived, potentially duplicating side effects.

Why This Change Was Made

The reply layer now consumes the typed cliTimeout.observedActivity fact recorded at the CLI boundary and marks the shared whole-turn retry state unsafe. Both outer retry gates—overload recovery and the one-shot transient retry—already consume that state; active-tool and background-task counts remain diagnostic only.

The only phase-mark consumer for these whole-turn gates is the shared execution-phase callback. Model-candidate fallback uses a separate delivery-evidence decision and does not consult this phase-mark state, so it is not part of this frozen outer-retry behavior change.

User Impact

CLI timeouts after observed activity now surface the existing partial-effects guidance without replaying the whole turn. Release-note context: prevents duplicate side effects after CLI timeouts.

Evidence

The requested directory-wide src/auto-reply run was attempted locally, but the shared host produced unrelated multi-minute timeouts and cross-suite state fallout; that run was stopped after 30 minutes and is not claimed as proof. Exact-head PR CI is green and is the canonical isolated broad validation.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 11, 2026
@steipete
steipete marked this pull request as ready for review August 11, 2026 16:55
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 1:01 PM ET / 17:01 UTC.

ClawSweeper review

What this changes

The PR makes a CLI timeout that reports observed activity unsafe for outer whole-turn retries, so OpenClaw returns existing partial-effects guidance instead of replaying the turn.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. This maintainer PR fixes a source-proven whole-turn retry path that can replay a CLI timeout after observed activity; current main lacks the typed-fact guard. No blocking patch defect found, but exact-head CI and acceptance of the deliberately more conservative recovery behavior remain before merge.

Priority: P1
Reviewed head: 092f1c35b2ad636c23cdc35a36b325a28f3f91b7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, owner-aligned repair with a credible regression scenario; exact-head CI is still needed before merge.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored deterministic retry fix is not subject to the external-contributor real-behavior-proof gate; the PR supplies focused red-to-green regression evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored deterministic retry fix is not subject to the external-contributor real-behavior-proof gate; the PR supplies focused red-to-green regression evidence.
Evidence reviewed 5 items Current-main retry gap: Current main checks only the shared unsafe-to-replay state before the overload and transient retry gates; it does not read the timeout's typed observed-activity fact, so the no-phase-mark timeout can reach the transient whole-turn retry.
Authoritative timeout fact: The CLI process boundary writes observedActivity into both no-output and overall timeout errors, making it the appropriate authoritative input rather than inferred tool counts.
Wrapper-safe lookup: The existing timeout finder validates the typed context and recursively follows error, cause, and aggregate errors; fallback failure summaries retain the terminal error as cause.
Findings None None.
Security None None.

How this fits together

Agent reply execution selects a model or CLI candidate and handles terminal failures. The CLI runner records timeout activity facts, and the reply error handler decides whether a whole turn may be retried or must surface a final failure.

flowchart LR
  A[Incoming agent turn] --> B[Model or CLI candidate]
  B --> C[CLI timeout activity fact]
  B --> D[Execution phase callback]
  C --> E[Reply error handler]
  D --> E
  E --> F{Safe to replay?}
  F -->|yes| G[Whole-turn retry]
  F -->|no| H[Partial-effects guidance]
Loading

Before merge

  • Resolve merge risk (P2) - Merging intentionally removes automatic whole-turn recovery after any CLI timeout with observed activity; a harmless observed output can now require the operator to retry manually, trading availability for avoiding duplicate side effects.
  • Resolve merge risk (P2) - Production code is net +5 lines; the added owner-boundary check has no redundant existing branch to remove because phase callbacks remain independently necessary for non-timeout observable activity.
  • Complete next step (P2) - This protected maintainer-owned PR needs human merge handling after exact-head CI, not an automated repair branch.
Agent review details

Security

None.

PR surface

Source +5, Tests 0. Total +5 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 1 +5
Tests 1 6 6 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 12 7 +5

Review metrics

Metric Value Why it matters
Production versus test LOC production +5; tests +0 net (6 added, 6 removed) The small production increase adds the missing owner-boundary safety predicate; the test replacement preserves the focused scenario while changing its expected outcome.

Merge-risk options

Maintainer options:

  1. Accept conservative retry behavior (recommended)
    Keep the no-replay policy for all observed CLI activity and merge once exact-head CI is green, accepting that some recoverable turns will now surface a final timeout.
  2. Pause for narrower activity semantics
    Hold the PR if maintainers want automatic retry to remain available after non-side-effecting CLI output, then define and prove a narrower authoritative activity fact.

Technical review

Best possible solution:

Keep the typed timeout check at the shared outer-retry owner, retain the phase callback for its independent activity signals, and land after exact-head CI confirms the conservative no-replay policy.

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

Yes, at source level: the focused pre-change scenario creates an observed CLI timeout without an execution-phase mark and demonstrates the current transient whole-turn replay path.

Is this the best way to solve the issue?

Yes. The reply error handler owns both outer retry gates, while the CLI boundary owns the typed activity fact; using the existing recursive timeout finder preserves that fact through fallback wrappers.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: A timed-out CLI turn can replay potentially side-effecting work in a normal agent execution path.
  • add merge-risk: 🚨 availability: The PR deliberately suppresses an existing automatic whole-turn retry after observed CLI activity, so affected turns may now end in a visible timeout instead of recovering.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored deterministic retry fix is not subject to the external-contributor real-behavior-proof gate; the PR supplies focused red-to-green regression evidence.

Label justifications:

  • P1: A timed-out CLI turn can replay potentially side-effecting work in a normal agent execution path.
  • merge-risk: 🚨 availability: The PR deliberately suppresses an existing automatic whole-turn retry after observed CLI activity, so affected turns may now end in a visible timeout instead of recovering.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored deterministic retry fix is not subject to the external-contributor real-behavior-proof gate; the PR supplies focused red-to-green regression evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the focused current PR and its sole commit; local historical traversal beyond available objects was incomplete. (role: current retry-path contributor; confidence: medium; commits: 092f1c35b2ad; files: src/auto-reply/reply/agent-runner-error-handler.ts, src/auto-reply/reply/agent-runner-execution-provider-failures.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for exact-head required CI to complete successfully before merging.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

@steipete
steipete merged commit 76ab9a7 into main Aug 11, 2026
199 of 200 checks passed
@steipete
steipete deleted the steipete/failover-b2-replay-safety branch August 11, 2026 17:13
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

1 participant