Repository navigation
fix: auto-reply gateway stalls in a zero-work drain loop after a queue drop policy change - #119331
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 1:13 AM ET / 05:13 UTC. ClawSweeper reviewWhat this changesThis PR makes auto-reply overflow summaries remain deliverable after later queue drop-policy changes and records queue-cap rejections or evictions accurately. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open. Current main still has the policy-gated summary rendering that can reschedule zero-work queue drains; this PR moves that boundary to the queue owner and has no blocking correctness finding in this review. Priority: P0 Review scores
Verification
How this fits togetherAuto-reply queues serialize follow-up agent work for a session. Queue admission and overflow-summary draining feed reply dispatch and Gateway chat state, which must either deliver a result or record an intentional skipped outcome. flowchart LR
Turn[Incoming turn] --> Queue[Session follow-up queue]
Queue --> Policy[Admission and drop policy]
Policy --> Summary[Overflow summary state]
Summary --> Drain[Queue drain]
Drain --> Dispatch[Reply and Gateway dispatch]
Dispatch --> Outcome[Delivered or recorded outcome]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +123, Tests +258. Total +381 across 22 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the shared queue-owner repair after rebasing onto current main and confirming the exact merge head preserves bounded draining, source-aligned summaries, and producer-owned queue-cap outcomes. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main has the policy-gated renderer and unconditional pending-work reschedule, while the PR provides an exact-head queue-runtime transcript for the same overflow then policy-transition sequence. Is this the best way to solve the issue? Yes. Separating already-produced summary state from future admission policy at the shared queue owner is better than discarding it later in the drain or adding a retry cap, both of which would either lose valid work or mask the producer-state defect. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 75ef5aebecb8. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (12 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review Addressed the P2 finding: moved orphaned summary accounting cleanup from the drain guard into the policy-transition owner ( |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Both findings addressed:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Both remaining findings addressed:
All local checks green: tsgo:core, tsgo:core:test, format, lint, 46 queue+helpers tests, 88 TUI tests, 6 orphaned-summary regression tests. Real-runtime proof unchanged: drainCycles 5001 -> 3, droppedCount 1 -> 0 at the flip. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review P1 finding addressed: elision compaction now propagates deferred-retry state to compact clones.
Regression: All local checks green: tsgo:core, tsgo:core:test, format, lint, 7 orphaned-summary regression tests, 46 queue+helpers tests, 88 TUI tests. Real-runtime proof unchanged: drainCycles 5001 -> 3. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Please review exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Exact-head production queue proof for I ran the real queue producer, runtime policy mutation, detached drain, summary renderer, queue cleanup, and timer scheduling from the exact PR checkout. The harness used synthetic messages and a recording follow-up callback; it did not touch an operator Gateway, live channel, credentials, or user state. Command: OPENCLAW_TEST_FAST=1 node --import tsx /tmp/openclaw-queue-proof.mtsObserved output: {
"exactHead": "095cb4d1158c6b954c1c60a6732d2f88ad33ace3",
"summarize": {
"overflowCount": 5,
"everyOverflowHasContent": true,
"overflow": [
"[Queue overflow] Dropped 1 message due to cap.\nSummary:\n- dropped A",
"[Queue overflow] Dropped 1 message due to cap.\nSummary:\n- dropped B",
"[Queue overflow] Dropped 2 messages due to cap.\nSummary:\n- dropped C1\n- dropped C2",
"[Queue overflow] Dropped 1 message due to cap.\nSummary:\n- dropped D",
"[Queue overflow] Dropped 1 message due to cap.\nSummary:\n- dropped E"
],
"survivorsDelivered": true,
"queueSettled": true
},
"transitions": [
{
"dropPolicy": "old",
"accepted": true,
"dispositions": ["second:queue-cap-old"],
"delivered": [
"[Queue overflow] Dropped 1 message due to cap.\nSummary:\n- first overflowed message",
"third queued message"
],
"queueSettled": true,
"timerFired": true
},
{
"dropPolicy": "new",
"accepted": false,
"dispositions": ["third:queue-cap-new"],
"delivered": [
"[Queue overflow] Dropped 1 message due to cap.\nSummary:\n- first overflowed message",
"second queued message"
],
"queueSettled": true,
"timerFired": true
}
]
}This exact-head run proves the previously bare context-isolated overflow deliveries now carry content, both policy transitions settle without forced cleanup, the retained item is delivered, the dropped/rejected item receives its producer-owned disposition, and an armed timer progresses. |
|
@clawsweeper re-review Exact head remains |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper review Please refresh the durable verdict for exact head |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Skipping the optional rebase rank-up move. Exact head |
|
Merged via squash.
|
…e drop policy change (openclaw#119331) * fix(auto-reply): preserve pending overflow summaries Co-authored-by: ml12580 <[email protected]> * fix(auto-reply): record queue cap outcomes * fix(auto-reply): align summary lines with sources --------- Co-authored-by: Peter Steinberger <[email protected]>
Closes #119312
What Problem This Solves
Fixes an issue where a session queue that overflowed under the default
summarizepolicy could stop the entire gateway after the operator changed future drops tooldornew. The pending overflow summary became unrenderable, so the drain repeatedly scheduled zero-work passes without yielding to timers, channel ingress, typing keepalives, or transport watchdogs.The same investigation found three connected outcome gaps in the queue owner: context-isolated summarize deliveries could become count-only prompts,
drop: oldevictions had no recorded intentional non-outcome, anddrop: newincorrectly surfaced the generic temporary-model-failure message.Reported with a production-path reproduction by @yetval. This PR preserves @ml12580's contributor credit while replacing the earlier transition-reconciliation implementation with a single queue-owner repair.
Why This Change Was Made
A queue's current drop policy controls future admission. Positive dropped counts, source identities, and summary lines describe already-produced overflow work and must remain deliverable until consumed. The old implementation mixed those two responsibilities and stored summary source/content in parallel structures that could lose their association.
This change:
drop: newas a skipped queue-full outcome with accurate visible text;drop: oldeviction as an intentional skipped outcome while preserving durable channel-ingress abandonment/retry behavior.No config, stored-data schema, protocol, plugin SDK, or public reply API changes.
User Impact
Operators can change queue drop policy after an overflow without wedging the gateway. Pending summaries are delivered once with correctly scoped content, retained queue work continues under the new policy, the queue is deleted, and normal event-loop timers continue running.
A newest-message queue-cap rejection now says the session queue is full instead of blaming a temporary model failure. A previously acknowledged Gateway turn later evicted by
drop: oldis recorded as an intentional skipped queue outcome rather than disappearing behind an earlier genericcompleteddiagnostic.Release-note context: prevent process-wide message stalls and misleading or silent queue-drop outcomes after follow-up queue overflow. Reported by @yetval.
Evidence
Before the fix, the issue's production-runtime harness observed 5,001 drain passes in 29 ms, only one real followup call, and a zero-delay timer that never fired.
Source-blind validation of the first repair confirmed responsiveness and policy-transition draining, then found the connected summarize-content,
drop: old, anddrop: newoutcome gaps described above. This exact head addresses each at the queue/admission owner. The exact-head production queue transcript is posted at #119331 (comment).Focused proof on exact head
095cb4d1158c6b954c1c60a6732d2f88ad33ace3after rebasing onto currentmain:oldandnewtransitions emittedqueue-cap-old/queue-cap-new, delivered the retained work, deleted the queue, and let an armed timer fire.node scripts/run-vitest.mjsover queue helpers, collect/dedupe/drain/state, agent-runner admission, dispatch finalization, Gateway chat/session, and embedded TUI suites — 24 unit-fast, 121 Gateway, 90 TUI, 448 auto-reply, and 130 E2E tests passed.oldandnew, exact original order, lifecycle settlement, queue deletion, bounded drain calls, and real timer progress without forced cleanup.drop: newemits the queue-full text, never the temporary-model-failure text, and recordsoutcome=skipped reason=queue-cap.drop: oldemits the source-ownedqueue-cap-olddisposition, retains durable ingress retry behavior, and records the acknowledged Gateway turn as intentionally skipped.node scripts/check-changed.mjs -- <changed files>could not use the configured remote route because Crabbox had no ready provider. The required trusted-source local fallback passed conflict/ratchet, formatting, API, boundary, dead-export, typecheck, lint, state-schema, database-first, sidecar, webhook, auth, and import-cycle checks on the current-main rebase.git diff --checkpassed.Production delta is net +81 lines; tests are net +300 lines. The production growth establishes the missing queue ownership boundary: paired source/content state, source-owned terminal queue dispositions, centralized accurate presentation, and Gateway recording. No live operator gateway or user-owned channel was touched.