Repository navigation
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bb60485220
ℹ️ 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".
| log.debug( | ||
| `reply session initialization conflicted; retrying in ${backoffMs}ms (attempt ${attemptIndex + 2}/${maxAttempts})`, | ||
| ); | ||
| await sleep(backoffMs); |
There was a problem hiding this comment.
Make session-init retry backoff abort-aware
When a reply run is canceled or the gateway is shutting down while this helper is between CAS-conflict attempts, this await sleep(...) cannot be interrupted and the loop does not check signal before starting the next attempt. get-reply.ts passes the reply abort signal into initSessionState as signal, so a canceled inbound turn can wait through the backoff and then still initialize/commit a session if the next attempt succeeds, instead of bailing immediately; please race the delay and/or the next iteration against the abort signal.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR addresses reply-session initialization CAS conflicts by making session-init conflicts explicitly typed and retryable with exponential backoff, so non-Telegram inbound paths no longer drop events when concurrent writers are updating the same session key.
Changes:
- Introduces
ReplySessionInitConflictErrorand throws it at the CAS-failure site after the existing stale-snapshot fast retry. - Adds
runWithSessionInitConflictRetry(jittered exponential backoff) and wrapsinitSessionStateso all inbound paths benefit. - Adds focused unit tests covering retry, exhaustion, abort behavior, and backoff bounds.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/auto-reply/reply/session.ts | Adds typed conflict error + retry helper and wires it into initSessionState; updates CAS-failure throw site. |
| src/auto-reply/reply/session.init-conflict-retry.test.ts | Adds unit tests validating conflict retry semantics and backoff schedule. |
| const sleep = | ||
| options?.sleep ?? | ||
| ((ms: number) => | ||
| new Promise<void>((resolve) => { | ||
| setTimeout(resolve, ms); | ||
| })); |
| log.debug( | ||
| `reply session initialization conflicted; retrying in ${backoffMs}ms (attempt ${attemptIndex + 2}/${maxAttempts})`, | ||
| ); | ||
| await sleep(backoffMs); |
| const SESSION_INIT_CONFLICT_MAX_ATTEMPTS = 5; | ||
| const SESSION_INIT_CONFLICT_BASE_BACKOFF_MS = 250; | ||
| const SESSION_INIT_CONFLICT_MAX_BACKOFF_MS = 4000; | ||
| const SESSION_INIT_CONFLICT_JITTER_MS = 100; |
|
Codex review: needs real behavior proof before merge. Reviewed July 12, 2026, 7:57 PM ET / 23:57 UTC. Summary PR surface: Source +71, Tests +99. Total +170 across 2 files. Reproducibility: yes. at source level: current main performs an initial CAS plus one immediate stale-snapshot retry and then throws, while the canonical issue supplies redacted Slack, WebChat, and heartbeat failure logs. A deterministic live concurrent-writer reproduction was not run during this read-only review. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Keep the retry at the common unlocked session-init boundary, make both the delay and next iteration abort-aware, add regression coverage for aborting during sleep, and obtain maintainer confirmation that bounded retry rather than durable re-enqueue is the intended residual-delivery policy. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main performs an initial CAS plus one immediate stale-snapshot retry and then throws, while the canonical issue supplies redacted Slack, WebChat, and heartbeat failure logs. A deterministic live concurrent-writer reproduction was not run during this read-only review. Is this the best way to solve the issue? Mostly yes: a common unlocked retry is narrower and more maintainable than duplicating recovery in every channel, but it is not merge-ready until cancellation is honored during backoff and maintainers confirm the intended behavior after retry exhaustion. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f87492539ba2. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +71, Tests +99. Total +170 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
|
Reply-session initialization retried a lost optimistic-concurrency commit exactly once, with no delay, inside the store writer lane. When another writer (restart recovery, a concurrent dashboard tab, an active reply run) was mid-commit on the same session key, both attempts lost the revision CAS within milliseconds and "reply session initialization conflicted" escaped to the caller — silently dropping the inbound event on webchat/Slack/heartbeat paths (openclaw#102400). Introduce a typed ReplySessionInitConflictError and retry the whole unlocked init attempt up to 5 times with jittered exponential backoff (250ms..4s). The sleep happens outside runExclusiveSessionStoreWrite so the writer lane is never held while waiting, each retry re-reads a fresh snapshot, and the error message shape is preserved for channel monitors (e.g. the Telegram poller) that already classify it as retryable. Fixes openclaw#102400
bb60485 to
c5a3dd7
Compare
|
Land-ready maintainer refresh at
Known boundary: persistent stale-active-session conflicts remain separate #101920 work. That fenced recovery should run only after this bounded transient retry exhausts. |
|
Merged via squash.
|
…ter backoff exhaustion Layer the openclaw#101909 fenced self-heal behind upstream openclaw#105754's typed-error backoff: while runWithSessionInitConflictRetry owns the retry budget, a repeated commit conflict propagates as ReplySessionInitConflictError (conflict-backoff) so transient races settle with no side effects. Only when the jittered backoff exhausts does initSessionState re-enter the attempt with selfHealRequested=true, unlocking the existing fenced recovery: revalidate the candidate under the store writer, drain foreign work admissions via interruptSessionWorkAdmissions outside the store-write lock, dispose the wedged session's MCP runtime, run harness reset hooks, and retry init exactly once (bounded by recoveryAttempted) before failing with clear context. Upstream retry semantics, abort handling, and the load-bearing conflict message shape are preserved.
…penclaw#105754) * fix(auto-reply): retry reply-session init CAS conflicts with backoff Reply-session initialization retried a lost optimistic-concurrency commit exactly once, with no delay, inside the store writer lane. When another writer (restart recovery, a concurrent dashboard tab, an active reply run) was mid-commit on the same session key, both attempts lost the revision CAS within milliseconds and "reply session initialization conflicted" escaped to the caller — silently dropping the inbound event on webchat/Slack/heartbeat paths (openclaw#102400). Introduce a typed ReplySessionInitConflictError and retry the whole unlocked init attempt up to 5 times with jittered exponential backoff (250ms..4s). The sleep happens outside runExclusiveSessionStoreWrite so the writer lane is never held while waiting, each retry re-reads a fresh snapshot, and the error message shape is preserved for channel monitors (e.g. the Telegram poller) that already classify it as retryable. Fixes openclaw#102400 * fix(auto-reply): cancel conflict backoff on abort * refactor(auto-reply): unify session init cancellation * refactor(auto-reply): isolate session conflict retry --------- Co-authored-by: oabdelmaksoud <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…it conflicts The previous digest (pinned 2026-07-13 01:18 UTC) predates upstream's reply-session-init CAS retry (openclaw/openclaw#105754, merged later that day) and the session-storage rework that followed. On that build, a session that loses the identity CAS wedges permanently — every Webex message in the room fails with "reply session initialization conflicted" (~15ms, no backoff) until the gateway restarts. Matches upstream issue #102020; maintainers verified the wedge is gone on current main (~2026-07-20). New digest is latest-browser 2026.6.34, built 2026-07-22. Also gitignore *.bak for local backup copies. Co-Authored-By: Claude Fable 5 <[email protected]>
After shared-core retry exhausts (openclaw#105754), QQBot was silently swallowing the ReplySessionInitConflictError at two levels: 1. outbound-dispatch.ts catch block consumed all errors from dispatchPromise without re-throwing any. 2. gateway.ts handleMessage catch only logged the error without sending a user-visible notice. This change makes dispatchOutbound re-throw only the reply-session init conflict so gateway.ts can surface a terminal Chinese-language notice to the user with an 8-char hex error reference number. The terminal notice is best-effort: QQBot currently has no durable spool or replay-claim system, so a failed notice delivery is logged at 'terminal_notice_failed' and the message is not falsely marked delivered. Durable ingress/replay is deferred to a follow-up PR. Uses the same message-regex pattern as Discord/Slack/Telegram/Signal since ReplySessionInitConflictError is not exported through the plugin SDK.
What Problem This Solves
Fixes #102400.
Reply-session initialization retried a lost optimistic-concurrency commit once, immediately, inside the session-store writer lane. A second revision race escaped as
reply session initialization conflicted, dropping inbound work on callers without a channel-level replay path.Why This Change Was Made
The retry belongs at
initSessionState, the shared owner for every inbound path. The change keeps the existing immediate stale-snapshot retry, then retries the unlocked outer attempt up to five times with the shared jittered exponential-backoff implementation. Each attempt rereads current state; no backoff holds the session-store writer lane.The maintainer refresh also makes the wait abort-aware, uses the initializer's single canonical
signalthroughout commit and retry cancellation, and isolates the typed conflict/retry policy in a production-owned module. Non-conflict failures still escape immediately.Persistent conflicts caused by stale active-session state remain a separate recovery mode tracked by #101920; this PR handles bounded transient compare-and-swap races before that recovery path should run.
User Impact
Transient session-init races no longer silently drop webchat, Slack, heartbeat, Discord, or other shared inbound work. Shutdown and turn cancellation interrupt an active retry delay instead of waiting or starting another attempt.
Evidence
fa78b6fe5e3d70a82fe0966f36057559309f530dtbx_01kxdtn1tvse42mvwf6whkgq2e: 4 focused files, 166/166 tests;tsgo:core;check:test-types; dead-export baseline; targeted oxlint; full build. Run 29253923193