Skip to content

fix: let slow auto-compaction run to its configured timeout instead of stopping at 6 minutes - #201928

Merged
obviyus merged 3 commits into
openclaw:mainfrom
chessing234:fix/compaction-stall-watchdog-201576
Nov 19, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
chessing234:fix/compaction-stall-watchdog-201576

Conversation

@chessing234

@chessing234 chessing234 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Root cause: src/sessions/session-controller.watchdog.ts:103 (base 0eb6488cd3) builds the reply watchdog's semantic deadline from the last progress plus 6 minutes and the open model requests only, so a nested compaction attempt's own deadline (compaction.timeoutSeconds, set in compaction-session-agent.ts:221) never counts and the turn is stopped as stalled once a long compaction summary has run past 6 minutes.

Fixes #201576

Thanks @kazuyuki-eguchi for the detailed report and timeline, and @chessing234 for the first fix in this PR (its two checks are kept as one regression in the watchdog suite).

What Problem This Solves

With agents.defaults.compaction.timeoutSeconds: 600, auto-compaction on a slow local model was cut off after about 6 minutes with Reply operation stalled, so the 600 s budget could never be used. The turn failed, the next turn hit the same overflow, and the cycle repeated.

User Impact

User impact: a quiet auto-compaction can now run until its own compaction.timeoutSeconds, and the turn continues once the summary arrives. Stop still cancels compaction at once, compaction still ends at its own timeout, and an ordinary stalled model call is still stopped at the usual window.

Why This Change Was Made

Compaction already registers with the reply watchdog as a nested maintenance attempt with its own deadline (refreshed while it makes progress). The watchdog honoured that deadline only as a hard stop, not as a reason the turn was not stalled. It covered the summary request only while it was open, measured from the last progress before compaction began. Now a live nested attempt's deadline counts toward the stall window, and when compaction finishes the stall window restarts from that point. Native runtime-owned waits already work this way. No new setting, timeout or wording.

The earlier version of this PR added a separate compaction-watchdog-allowance module around recovery compaction. It is removed: the watchdog owner already has the hook, and this covers every compaction that runs through the compaction session, not only recovery.

Evidence

Isolated Gateway (ocx src, pinned Bun, task-owned state), reporter's compaction config (safeguard, qualityGuard, midTurnPrecheck, timeoutSeconds: 600), and a scripted local OpenAI-compatible model. A turn reads large files, mid-turn context pressure triggers auto-compaction, and the compaction summary request stays quiet. Only the Gateway process's clock is stepped. Observed lines: #201928 (comment)

Case Base 0eb6488cd3 (main) This PR
Quiet summary, answered after 420 s lane task error: lane=main durationMs=427663 error="Reply operation stalled", caller_signal_aborted; user sees "Your request couldn't be completed." auto-compaction succeeded ...; retrying prompt, turn answers
Quiet past 600 s n/a compaction ends at its own timeout ([compaction-diag] fallback ... reason=timeout), turn continues
User Stop during compaction n/a chat.abort -> compaction ends 190 ms later, agent run aborted
Ordinary model call quiet 370 s, no compaction request closed at the window, then retried same

Regression: session-controller.watchdog.test.ts "lets quiet compaction outlast the stall window while Stop still cancels it" fails on base (stopped as stalled at 7 min) and passes here.

Change size against the merge base: production +16/-2 (one file), tests +19. The contributor's new module and its test (+89) and the compaction-runtime.ts wrapper are gone.

Merge danger: two-way door, no stored state or config change; revert restores the old window. Blast radius: replies whose turn runs compaction (embedded runtime), and only while compaction runs; ordinary model and tool stalls are unchanged.

The reply stall watchdog aborted overflow compaction at about six minutes, before compaction.timeoutSeconds could finish.
The repository formatter wants the timeout allowance on one line so the overflow compaction change stays check-clean.
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Nov 19, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR lets nested compaction use its existing timeout and gives the resumed turn a fresh stall window.

Example: Auto-compaction has timeoutSeconds=600 and its quiet summary finishes after 420 seconds.

  • Before: The watchdog stops the turn as stalled when the summary request ends.
  • After: Compaction completes and the turn resumes without being charged for the compaction interval.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with supplied Gateway behavior proof, a reported red/green regression, and no actionable findings; ordinary exact-head CI remains in progress.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The supplied candidate-pinned logs exercise automatic compaction through an isolated Gateway and real OpenAI-compatible HTTP transport with a scripted local model and accelerated process-local clocks, showing successful completion beyond six minutes, timeout fallback, user cancellation, and unchanged ordinary-stall recovery; this resolves the previous review's proof gap.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A slow automatic compaction is interrupted before its configured timeout, preventing the turn from recovering from context pressure.
Reason: Restores the existing compaction timeout contract through its current owner without adding configuration, public APIs, or persistence.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a demonstrated compaction failure still present on current main, with no actionable introduced defects found.

Priority: P2
Reviewed head: 3c79694b940c14ddc39d0a39541af98050d070ba

Before merge

None.

Findings

None.

Agent review details

How this fits together

The session-controller watchdog combines progress, request deadlines, and execution deadlines to decide whether an active reply may continue or must stop; compaction registers as a nested attempt under that owner.

flowchart TD
  A[Active reply] --> B[Session controller]
  B --> C[Nested compaction]
  C --> D[Summary model request]
  C --> E[Watchdog deadline]
  E --> F[Continue or stop reply]
  D --> G[Resume turn]
Loading

Technical review

Best possible solution:

Use the existing watchdog's nested compaction deadline and release handoff while preserving foreground execution limits and user cancellation.

Do we have a high-confidence way to reproduce the issue?

Current-main source explains the failure after the summary request closes, and the supplied isolated Gateway comparison demonstrates that failure; this read-only review ran no reproduction.

Is this the best way to solve the issue?

The revised patch is the smallest complete fix using the existing watchdog owner: it honors nested maintenance deadlines and renews the semantic horizon at handoff without another wrapper or setting.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f96a979a0f3b.

Provenance checked

  • Nested compaction ownership and independent execution deadlines keeps the original intent (44fc554: Preserve the foreground attempt and its resources while compaction owns a separate nested execution deadline.)
  • Semantic horizon after owned work completes changes intended behavior with a stated reason (4d2081f: Avoid retroactively treating a completed native-owned wait as stalled during answer settlement.)
  • Request deadline allowance keeps the original intent (a8adfc3: Allow bounded model-request timeout recovery before aborting the entire reply.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +14, Tests +19. Total +33 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 16 2 +14
Tests 1 19 0 +19
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 35 2 +33

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: same_root_cause
Canonical: #201576
Summary: This PR repairs the configured-compaction-budget failure documented by the linked open issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Premature cancellation breaks long-context recovery for slow compaction requests, with a limited affected workflow and a focused repair.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-19T16:32:35.176Z sha 17b08b9 :: needs real behavior proof before merge. :: none

Reviewed November 19, 2026, 1:13 PM ET / 18:13 UTC (Revision 2).

…eadline

The reply watchdog measured a quiet compaction against the 6-minute semantic window
from the last progress before compaction began. Its summary request was covered only
while open, so once a long summary ended the turn was stopped as stalled even though
the nested compaction attempt already declared its own deadline (compaction.timeoutSeconds).

- The watchdog now counts a live nested maintenance attempt's execution deadline in the
  semantic deadline, and releasing it starts the semantic horizon (never retroactively),
  as runtime-owned waits already do.
- Drop the separate compaction-watchdog-allowance module; the watchdog owner already
  has the hook. Keep its two checks as one compact watchdog regression.
@obviyus

obviyus commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator
Case Base 0eb6488cd3 (main) This PR
Quiet summary, answered after 420 s lane task error: lane=main durationMs=427663 error="Reply operation stalled", caller_signal_aborted; user sees "Your request couldn't be completed." auto-compaction succeeded ...; retrying prompt, turn answers
Quiet past 600 s n/a compaction ends at its own timeout ([compaction-diag] fallback ... reason=timeout), turn continues
User Stop during compaction n/a chat.abort -> compaction ends 190 ms later, agent run aborted
Ordinary model call quiet 370 s, no compaction request closed at the window, then retried same

Observed proof lines for #201576 (isolated ocx src Gateway, reporter compaction config, scripted local OpenAI-compatible model, only the Gateway process clock stepped). Base main 0eb6488cd3, candidate 3c79694b94.

BASE main 0eb6488cd3ce5918c4d1fe48d0a4bb4cd2d290a2, summary answered 2 s after a 420 s step (runs/base-cfg-summary420):
  22:28:00.853 [agent/embedded] predicted context pressure detected (attempt 1/3); attempting auto-compaction for local/m
  stepped process-local clocks by 420000ms
  22:28:07.599 [compaction-diag] end ... trigger=budget ... outcome=failed reason=unknown durationMs=426654
  22:28:07.635 [diagnostic] lane task error: lane=main durationMs=427663 error="Reply operation stalled" errorName=AbortError taskKind=turn ... staleReason=no_activity
  22:28:07.647 [model-fallback/decision] model fallback chain stopped: reason=caller_signal_aborted candidate=local/m errorName=AbortError
  transcript: custom "Your request couldn't be completed." (a later re-run then compacted instantly because the fixture answers only the first summary slowly)
  Debug-instrumented base rerun (scratch only, discarded): compaction request begin deadline=start+600000; request end at +425 s; watchdog stop semantic_stall deadlineAtMs = lastProgress(reply:block_delivered)+360000.

CANDIDATE 3c79694b94 (tree identical; runs labelled "17b08b95fc+watchdog-maintenance (uncommitted)" were taken on the same content before the commit):
  summary after 420 s (runs/cand-summary420): predicted context pressure -> compaction-safeguard quality fallback -> "auto-compaction succeeded for local/m; retrying prompt"; no lane task error; final assistant "P201576-ANSWER request 14".
  control quiet past 600 s (runs/cand-timeout610, 610 s step, summary never answered): "[compaction-diag] fallback ... trigger=budget ... reason=timeout summary=deterministic" -> "auto-compaction succeeded; retrying prompt"; no watchdog stop; final "P201576-ANSWER request 11". Compaction ended at its own timeout.
  control user Stop (runs/cand-stop): 22:51:09.630 chat.abort requested -> 22:51:09.820 compaction-diag end outcome=failed -> lane task error "agent run aborted"; fixture: compaction request closed-by-gateway.
  control ordinary stall, no compaction, 370 s step: base (runs/base-stall370) and candidate (runs/cand-stall370) identical: quiet request closed-by-gateway right after the step, existing model-call recovery retried, final "P201576-ANSWER request 2".

Regression (vitest-source): src/sessions/session-controller.watchdog.test.ts "lets quiet compaction outlast the stall window while Stop still cancels it"
  base 0eb6488cd3: FAIL "expected vi.fn() to not be called at all, but actually been called 1 times" (stopped as stalled at 7 min)
  candidate: 66/66 passed

@openclaw-barnacle openclaw-barnacle Bot removed the agents Agent runtime and tooling label Nov 19, 2026
@obviyus obviyus changed the title fix: let quiet compaction finish before the stall watchdog fix: let slow auto-compaction run to its configured timeout instead of stopping at 6 minutes Nov 19, 2026
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 19, 2026
@obviyus
obviyus merged commit ea63462 into openclaw:main Nov 19, 2026
205 of 211 checks passed
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks @chessing234 for the fix and @kazuyuki-eguchi for the clear report. This is merged in ea63462: a quiet auto-compaction now counts as progress for the reply stall watchdog until its own compaction.timeoutSeconds deadline, so a summary that takes longer than the six-minute window finishes and the turn answers. Compaction still ends at its configured timeout, Stop still cancels it at once, and a normal stalled model call is still stopped at the existing window.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…f stopping at 6 minutes (openclaw#201928)

Root cause: `src/sessions/session-controller.watchdog.ts:103` (base `c59f66b73e`) builds the reply watchdog's semantic deadline from the last progress plus 6 minutes and the open model requests only, so a nested compaction attempt's own deadline (`compaction.timeoutSeconds`, set in `compaction-session-agent.ts:221`) never counts and the turn is stopped as stalled once a long compaction summary has run past 6 minutes.

Fixes openclaw#201576

Thanks @kazuyuki-eguchi for the detailed report and timeline, and @chessing234 for the first fix in this PR (its two checks are kept as one regression in the watchdog suite).

## What Problem This Solves

With `agents.defaults.compaction.timeoutSeconds: 600`, auto-compaction on a slow local model was cut off after about 6 minutes with `Reply operation stalled`, so the 600 s budget could never be used. The turn failed, the next turn hit the same overflow, and the cycle repeated.

## User Impact

User impact: a quiet auto-compaction can now run until its own `compaction.timeoutSeconds`, and the turn continues once the summary arrives. Stop still cancels compaction at once, compaction still ends at its own timeout, and an ordinary stalled model call is still stopped at the usual window.

## Why This Change Was Made

Compaction already registers with the reply watchdog as a nested maintenance attempt with its own deadline (refreshed while it makes progress). The watchdog honoured that deadline only as a hard stop, not as a reason the turn was not stalled. It covered the summary request only while it was open, measured from the last progress before compaction began. Now a live nested attempt's deadline counts toward the stall window, and when compaction finishes the stall window restarts from that point. Native runtime-owned waits already work this way. No new setting, timeout or wording.

The earlier version of this PR added a separate `compaction-watchdog-allowance` module around recovery compaction. It is removed: the watchdog owner already has the hook, and this covers every compaction that runs through the compaction session, not only recovery.

## Evidence

Isolated Gateway (`ocx src`, pinned Bun, task-owned state), reporter's compaction config (`safeguard`, `qualityGuard`, `midTurnPrecheck`, `timeoutSeconds: 600`), and a scripted local OpenAI-compatible model. A turn reads large files, mid-turn context pressure triggers auto-compaction, and the compaction summary request stays quiet. Only the Gateway process's clock is stepped. Observed lines: openclaw#201928 (comment)

| Case | Base `c59f66b73e` (main) | This PR |
| --- | --- | --- |
| Quiet summary, answered after 420 s | `lane task error: lane=main durationMs=427663 error="Reply operation stalled"`, `caller_signal_aborted`; user sees "Your request couldn't be completed." | `auto-compaction succeeded ...; retrying prompt`, turn answers |
| Quiet past 600 s | n/a | compaction ends at its own timeout (`[compaction-diag] fallback ... reason=timeout`), turn continues |
| User Stop during compaction | n/a | `chat.abort` -> compaction ends 190 ms later, `agent run aborted` |
| Ordinary model call quiet 370 s, no compaction | request closed at the window, then retried | same |

Regression: `session-controller.watchdog.test.ts` "lets quiet compaction outlast the stall window while Stop still cancels it" fails on base (stopped as stalled at 7 min) and passes here.

Change size against the merge base: production +16/-2 (one file), tests +19. The contributor's new module and its test (+89) and the `compaction-runtime.ts` wrapper are gone.

Merge danger: two-way door, no stored state or config change; revert restores the old window. Blast radius: replies whose turn runs compaction (embedded runtime), and only while compaction runs; ordinary model and tool stalls are unchanged.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
…f stopping at 6 minutes (#201928)

Root cause: `src/sessions/session-controller.watchdog.ts:103` (base `0eb6488cd3`) builds the reply watchdog's semantic deadline from the last progress plus 6 minutes and the open model requests only, so a nested compaction attempt's own deadline (`compaction.timeoutSeconds`, set in `compaction-session-agent.ts:221`) never counts and the turn is stopped as stalled once a long compaction summary has run past 6 minutes.

Fixes #201576

Thanks @kazuyuki-eguchi for the detailed report and timeline, and @chessing234 for the first fix in this PR (its two checks are kept as one regression in the watchdog suite).

## What Problem This Solves

With `agents.defaults.compaction.timeoutSeconds: 600`, auto-compaction on a slow local model was cut off after about 6 minutes with `Reply operation stalled`, so the 600 s budget could never be used. The turn failed, the next turn hit the same overflow, and the cycle repeated.

## User Impact

User impact: a quiet auto-compaction can now run until its own `compaction.timeoutSeconds`, and the turn continues once the summary arrives. Stop still cancels compaction at once, compaction still ends at its own timeout, and an ordinary stalled model call is still stopped at the usual window.

## Why This Change Was Made

Compaction already registers with the reply watchdog as a nested maintenance attempt with its own deadline (refreshed while it makes progress). The watchdog honoured that deadline only as a hard stop, not as a reason the turn was not stalled. It covered the summary request only while it was open, measured from the last progress before compaction began. Now a live nested attempt's deadline counts toward the stall window, and when compaction finishes the stall window restarts from that point. Native runtime-owned waits already work this way. No new setting, timeout or wording.

The earlier version of this PR added a separate `compaction-watchdog-allowance` module around recovery compaction. It is removed: the watchdog owner already has the hook, and this covers every compaction that runs through the compaction session, not only recovery.

## Evidence

Isolated Gateway (`ocx src`, pinned Bun, task-owned state), reporter's compaction config (`safeguard`, `qualityGuard`, `midTurnPrecheck`, `timeoutSeconds: 600`), and a scripted local OpenAI-compatible model. A turn reads large files, mid-turn context pressure triggers auto-compaction, and the compaction summary request stays quiet. Only the Gateway process's clock is stepped. Observed lines: #201928 (comment)

| Case | Base `0eb6488cd3` (main) | This PR |
| --- | --- | --- |
| Quiet summary, answered after 420 s | `lane task error: lane=main durationMs=427663 error="Reply operation stalled"`, `caller_signal_aborted`; user sees "Your request couldn't be completed." | `auto-compaction succeeded ...; retrying prompt`, turn answers |
| Quiet past 600 s | n/a | compaction ends at its own timeout (`[compaction-diag] fallback ... reason=timeout`), turn continues |
| User Stop during compaction | n/a | `chat.abort` -> compaction ends 190 ms later, `agent run aborted` |
| Ordinary model call quiet 370 s, no compaction | request closed at the window, then retried | same |

Regression: `session-controller.watchdog.test.ts` "lets quiet compaction outlast the stall window while Stop still cancels it" fails on base (stopped as stalled at 7 min) and passes here.

Change size against the merge base: production +16/-2 (one file), tests +19. The contributor's new module and its test (+89) and the `compaction-runtime.ts` wrapper are gone.

Merge danger: two-way door, no stored state or config change; revert restores the old window. Blast radius: replies whose turn runs compaction (embedded runtime), and only while compaction runs; ordinary model and tool stalls are unchanged.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit ea63462)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 507c007d1344991cceb0110b114e5c80b23ce0fb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Reply stall watchdog (~360s) aborts embedded auto-compaction before the configured compaction.timeoutSeconds (600s) can take effect

2 participants