Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesEnforce timeout ceilings with monotonic time while preserving epoch-valued compaction deadline options. Example: A streaming compaction has a 10-second ceiling when the host clock moves backward by 300 seconds.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a focused, correct repair for clock-sensitive compaction deadlines still present on current main; no actionable findings remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCompaction passes progress callbacks and cancellation signals through the host watchdog to the shared timeout helper, which schedules aborts and returns completion or timeout errors. flowchart TD
A[Sessions compact CLI] --> B[Gateway compaction]
B --> C[Host watchdog]
C --> D[Context engine and summary]
D --> E[Progress callback]
E --> F[Shared monotonic timeout]
F --> D
Technical reviewBest possible solution: Merge the focused clock repair with the existing timeout owner, epoch deadline contract, and regression coverage intact. Do we have a high-confidence way to reproduce the issue? Current-main source shows wall-clock subtraction controlling timer rearming, and the contributor supplies before/after Gateway traces for both jump directions; this review executed no target code. Is this the best way to solve the issue? This is the smallest complete repair: use monotonic time for the existing helper's elapsed ceiling and retain epoch conversion at the public wrapper boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ccc1e16ace23. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +5, Tests +54. Total +59 across 4 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 26, 2026, 9:41 PM ET / October 27, 2026, 01:41 UTC (Revision 4). |
ec5a187 to
899f672
Compare
|
🦞👀 Re-review progress:
|
runAbortableTimeout seeded the max-total deadline with Date.now() and re-read Date.now() on every progress reset, while setTimeout arms on the monotonic clock. A wall-clock jump during compaction inflated the remaining budget (a hung compaction lost its safety abort) or collapsed it (premature abort mid-write). Seed and re-read the ceiling with performance.now() in that helper, the one owner of both the deadline and the timer. Keep the plugin-SDK deadlineAt option epoch-valued: the host watchdog and the delegated summary share that ceiling, so compactWithSafetyTimeout converts it once into an elapsed budget instead of moving a shipped parameter to another clock.
899f672 to
b0136ac
Compare
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
Runtime proof on head a92551d against main 137e96f: built Gateway in a secretless Node 24.22.1 container. History was created through normal Gateway turns, then the shipped
|
|
Landed in c61f6e9. Thanks @SunnyShu0925. Compaction no longer times out early after a clock jump. |
…penclaw#184293) fix(agents): keep the compaction safety deadline on the monotonic clock The compaction safety deadline was measured with the wall clock, so a forward clock step ended a healthy compaction early with a timeout. The deadline now uses monotonic time; the progress window and hard ceiling are unchanged. Evidence: shipped sessions.compact on a built Gateway with a slow, continuously progressing summarizer and Date.now stepped forward 60 seconds inside the process only. On main compaction timed out after 2.8s and 2.6s (twice); with this change it completed in 14.8s and 17.9s (twice), like the no-step runs on both refs. Production 9 lines. Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]>
…184293) fix(agents): keep the compaction safety deadline on the monotonic clock The compaction safety deadline was measured with the wall clock, so a forward clock step ended a healthy compaction early with a timeout. The deadline now uses monotonic time; the progress window and hard ceiling are unchanged. Evidence: shipped sessions.compact on a built Gateway with a slow, continuously progressing summarizer and Date.now stepped forward 60 seconds inside the process only. On main compaction timed out after 2.8s and 2.6s (twice); with this change it completed in 14.8s and 17.9s (twice), like the no-step runs on both refs. Production 9 lines. Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit c61f6e9) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 8bb15647bfa8b8054e92728d6ea0b8abe5b92920)
…184293) fix(agents): keep the compaction safety deadline on the monotonic clock The compaction safety deadline was measured with the wall clock, so a forward clock step ended a healthy compaction early with a timeout. The deadline now uses monotonic time; the progress window and hard ceiling are unchanged. Evidence: shipped sessions.compact on a built Gateway with a slow, continuously progressing summarizer and Date.now stepped forward 60 seconds inside the process only. On main compaction timed out after 2.8s and 2.6s (twice); with this change it completed in 14.8s and 17.9s (twice), like the no-step runs on both refs. Production 9 lines. Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]> Beta.5 baseline adaptation: Retain the native beta.5 owners, fixtures and public contracts; add focused regression controls and bounded fixture extraction; apply checkout formatting. (cherry picked from commit c61f6e9) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 8afb085fe88876df4c037ef7dc14fa8b4a4d12fc)
What Problem This Solves
Compaction enforces two nested deadlines: a per-progress window (
timeoutMs, 180 s by default) re-armed on every progress tick, and a hard ceiling of ten windows. The helper owning both seeded the ceiling withDate.now()and re-readDate.now()on every re-arm, whilesetTimeoutruns on Node's monotonic clock.A host clock correction (NTP resync, manual time change) therefore distorted the remaining budget: a backward jump inflated it so a hung compaction lost its safety abort; a forward jump collapsed it, aborting compaction mid-write.
Why This Change Was Made
The deadline and the timer enforcing it must share one clock.
src/node-host/with-timeout.tsowns both, so the ceiling is seeded and re-read withperformance.now(); that single owner fixes everyrunAbortableTimeoutcaller.deadlineAtstays epoch-valued.compactWithSafetyTimeoutis exported fromopenclaw/plugin-sdk/agent-harness-runtime(v2026.10.7) and documentsdeadlineAtas epoch ms, shared by the host watchdog and the delegated summary;CompactionWatchdog.deadlineAtandcompactionDeadlineAtstay epoch-valued too. The wrapper converts that epoch ceiling once into an elapsed budget (deadlineAt - Date.now()) and the helper enforces the budget monotonically, so an existing plugin passingdeadlineAt: Date.now() + 1000still gets one second.Boundary: the conversion happens once, at wrapper entry. For a delegated summary that entry runs after the caller's awaits, so a wall-clock step in that gap still moves that summary's budget by the step, capped at one window; the host ceiling bounding the whole operation is monotonic, so the operation still cannot outlive it.
User Impact
Compaction is no longer aborted prematurely or left hanging when the host clock jumps mid-operation, at any window size, and plugin-supplied
deadlineAtvalues keep their epoch meaning.Evidence
Real Gateway compaction over the shipped CLI
node openclaw.mjs gatewayserves the session andnode openclaw.mjs sessions compact agent:main:proof --jsonstarts a real manual compaction. A loopback OpenAI-compatible provider streams the summary so the watchdog sees progress; onlyDate.nowis shifted, 2.5 s into the summary. The ceiling is 10 s (10 × 1 s windows).Pre-fix is the same build with the two
with-timeout.tslines reverted toDate.now()(matchingorigin/main); post-fix is the PR head (a92551de).Shipped SDK matrix (9 cases)
compactContextEngineWithSafetyTimeout/compactWithSafetyTimeoutin a real Node process with real timers and aborts; onlyDate.nowshifted. Current head (a92551de) passes 9/9,origin/main5/9 (backward rows keep running, forward rows abort early, epoch rows misread). Key rows (windows aretimeoutMs; ceiling is ten):deadlineAt = Date.now()+400Regression tests
Both jump directions fail with
src/node-host/with-timeout.tsreverted toorigin/main(expected false to be truebackward,expected true to be falseforward);treats a caller-supplied deadlineAt as epoch msfails on the earlier head and passes now. Suites:with-timeout.test.ts6/6,embedded-agent-runner.compaction-safety-timeout.test.ts10/10,delegate-watchdog.test.ts5/5,agent-session-compaction.test.ts18/18,run.compaction-runtime.test.ts27/27.Collision check: no open PR touches
with-timeout.tsorcompaction-safety-timeout.ts, andorigin/mainstill seeds the ceiling withDate.now().