mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
fix(agents): clamp compaction steer retry wait to remaining delivery window
The compaction retry loop checked the delivery-timeout deadline before choosing a fixed backoff delay, then slept that whole delay. When the remaining window was shorter than the next backoff entry, the final retry could sleep past the deadline, overrunning the delivery timeout the retry is meant to stay within. Clamp the wait to the remaining window (min(scheduledDelay, deadline - now)) and stop retrying once no time remains, so compaction waiting never exceeds the delivery timeout. Addresses the near-deadline overrun raised in ClawSweeper review of #86606.
This commit is contained in:
committed by
Peter Steinberger
parent
a7b8e6a5a9
commit
ea2e9ce8bd
@@ -286,10 +286,20 @@ async function resolveActiveWakeWithRetries(
|
||||
}
|
||||
// Use the next scheduled backoff delay; once the schedule is exhausted,
|
||||
// keep using its last entry until the deadline is reached.
|
||||
const delayMs =
|
||||
const scheduledDelayMs =
|
||||
compactionRetryDelaysMs[
|
||||
Math.min(compactionRetryIndex, compactionRetryDelaysMs.length - 1)
|
||||
] ?? 0;
|
||||
// Clamp the wait to the remaining delivery window so the final retry does
|
||||
// not sleep past the deadline (which would overrun the delivery timeout).
|
||||
// If no time remains, stop retrying and let the fallback handle it.
|
||||
const delayMs =
|
||||
compactionDeadlineMs === undefined
|
||||
? scheduledDelayMs
|
||||
: Math.min(scheduledDelayMs, compactionDeadlineMs - Date.now());
|
||||
if (delayMs <= 0 && compactionDeadlineMs !== undefined) {
|
||||
break;
|
||||
}
|
||||
await waitForAnnounceRetryDelay(delayMs, signal);
|
||||
if (signal?.aborted) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user