fix(announce): break infinite retry loop with max attempts and expiry#18444
Merged
steipete merged 2 commits intoopenclaw:mainfrom Feb 16, 2026
Merged
Conversation
…openclaw#18264) When runSubagentAnnounceFlow returns false (deferred), finalizeSubagentCleanup resets cleanupHandled=false and removes from resumedRuns, allowing retryDeferredCompletedAnnounces to pick it up again. If the underlying condition persists (stale registry data, transient state), this creates an infinite loop delivering 100+ announces over hours. Fix: - Add announceRetryCount + lastAnnounceRetryAt to SubagentRunRecord - finalizeSubagentCleanup: after MAX_ANNOUNCE_RETRY_COUNT (3) failed attempts or ANNOUNCE_EXPIRY_MS (5 min) since endedAt, mark as completed and stop - resumeSubagentRun: skip entries that have exhausted retries or expired - retryDeferredCompletedAnnounces: force-expire stale entries
Contributor
Additional Comments (1)
The other completion-related fields ( Prompt To Fix With AIThis is a comment left during a code review.
Path: src/agents/subagent-registry.ts
Line: 430:441
Comment:
**Stale retry state carried into replacement run**
`replaceSubagentRunAfterSteer` spreads `...source` but doesn't explicitly reset `announceRetryCount` or `lastAnnounceRetryAt`. If the previous run had exhausted its retry budget before the steer-restart, the replacement run inherits those values and could be immediately force-expired by the guards in `resumeSubagentRun` (lines 109-113) without ever attempting announce delivery.
The other completion-related fields (`endedAt`, `outcome`, `cleanupCompletedAt`, `cleanupHandled`, `suppressAnnounceReason`) are all explicitly reset here — the new fields should be too.
```suggestion
const next: SubagentRunRecord = {
...source,
runId: nextRunId,
startedAt: now,
endedAt: undefined,
outcome: undefined,
cleanupCompletedAt: undefined,
cleanupHandled: false,
suppressAnnounceReason: undefined,
announceRetryCount: undefined,
lastAnnounceRetryAt: undefined,
archiveAtMs,
runTimeoutSeconds,
};
```
How can I resolve this? If you propose a fix, please make it concise. |
Address review feedback: the spread operator carries stale retry state into replacement runs, potentially causing immediate force-expiration without ever attempting announce delivery.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #18264
Problem
When
runSubagentAnnounceFlowrepeatedly returnsfalse(deferred),finalizeSubagentCleanupresetscleanupHandled = falseand removes the entry fromresumedRuns, allowingretryDeferredCompletedAnnouncesto pick it up again immediately. If the underlying condition persists (stale registry data, transient state after cron deletion), this creates an infinite loop delivering 100+ announces over 3+ hours.The loop persists even after the originating cron job is disabled/deleted, because the subagent registry is persisted to disk and restored on gateway restart.
Root Cause
In
subagent-registry.ts,finalizeSubagentCleanup():Fix
announceRetryCountonSubagentRunRecord. AfterMAX_ANNOUNCE_RETRY_COUNT(3) failed attempts, mark as completed.ANNOUNCE_EXPIRY_MS(5 min sinceendedAt) are force-expired in bothresumeSubagentRunandretryDeferredCompletedAnnounces.announceRetryCount,lastAnnounceRetryAt) persist to the registry, surviving gateway restarts.Testing
Greptile Summary
This PR adds loop-guard protections to the subagent announce retry mechanism to fix an infinite retry loop (#18264). When
runSubagentAnnounceFlowrepeatedly returnsfalse, the code now tracks retry attempts (announceRetryCount) and enforces both a max retry count (3) and a time-based expiry (5 min sinceendedAt). Guards are added at three points:resumeSubagentRun,finalizeSubagentCleanup, andretryDeferredCompletedAnnounces.replaceSubagentRunAfterSteerdoes not resetannounceRetryCount/lastAnnounceRetryAtwhen creating a replacement run — a steered replacement could inherit an exhausted retry budget and be immediately force-expired.finalizeSubagentCleanupretry-counting path would strengthen confidence.Confidence Score: 3/5
Last reviewed commit: efe0541