Repository navigation
Conversation
… deadline When a long-running task is accidentally wrapped in `withDiagnosticPhase` (as happened with `channels.telegram.start-account` prior to openclaw#82592), the phase entry remains on `activePhaseStack` indefinitely. The liveness monitor reports this as the current phase in every heartbeat, causing the gateway health status to show 'degraded' with sustained event loop delay warnings even when the channel is fully functional. This adds a defensive eviction mechanism: `getCurrentDiagnosticPhase()` now checks the age of active phases and removes any that exceed a 5-minute maximum lifetime. Evicted phases are recorded as completed (with an `evicted: true` detail flag) so they remain visible in `recentPhases` for post-mortem analysis without continuing to pollute the active phase report. Production evidence (OpenClaw 2026.5.12, Raspberry Pi 5): - channels.telegram.start-account phase remained active for 12+ hours (44,696,816ms as reported in liveness warnings) - Gateway reported 'degraded' with eventLoopDelayMaxMs=1414.5, p99=60.6ms - Agent runs completed successfully but Telegram sendMessage calls were silently dropped under event loop pressure - Service restart immediately resolved the issue This complements openclaw#82592 (which moved the trace to only cover the handoff) by adding a safety net that prevents ANY future phase from sticking indefinitely, regardless of which code path wraps it.
|
Codex review: needs real behavior proof before merge. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: Partially: source inspection shows a never-settling PR rating Rank-up moves:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. PR egg Where did the egg go?
Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review findings
Review detailsBest possible solution: Land a maintainer-approved diagnostic eviction policy only with deterministic unit coverage for stale and non-stale phases plus after-fix runtime evidence; otherwise rely on the merged startup handoff fix for the known Telegram incident. Do we have a high-confidence way to reproduce the issue? Partially: source inspection shows a never-settling Is this the best way to solve the issue? Unclear. Generic eviction is plausible defense-in-depth, but the hardcoded global lifetime needs maintainer approval and the PR must prove the behavior with a real assertion and after-fix runtime evidence. Label justifications:
Full review comments:
Overall correctness: patch is incorrect What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 98256b192bc8. |
|
Related issues and PRs:
|
Production Validation: Eviction Mechanism WorkingTested on Raspberry Pi 5 (4GB, ARM64) running OpenClaw 2026.5.12. The BEFORE (unpatched v2026.5.12)Liveness warning at T+2min after restart — phase is stuck on The AFTER (patched with 30s eviction deadline)Same startup conditions, liveness warning at T+1min53s — phase has been evicted from the stack: Key differences:
Timeline
This confirms the eviction mechanism works end-to-end in production: stale phases are removed from the active stack, properly recorded with their duration, and no longer cause false |
|
@clawsweeper Added production validation above showing the eviction mechanism working end-to-end. The key evidence: unpatched shows |
Problem
On OpenClaw 2026.5.12 (Raspberry Pi 5, ARM64, Debian bookworm), the Telegram channel
startAccountwas wrapped inwithDiagnosticPhase("channels.telegram.start-account", ...)which tracked the entire long-running polling loop as an active phase. Since Telegram polling never resolves (by design), the phase remained onactivePhaseStackindefinitely — for over 12 hours in this incident.Impact: The liveness monitor reported
phase=channels.telegram.start-accountwith a duration of 44,696,816ms in every heartbeat. The gateway health status showed "degraded" with sustained event loop delay warnings (eventLoopDelayMaxMs=1414.5,p99=60.6ms). Under this pressure, agent runs completed successfully but outbound TelegramsendMessagecalls were silently dropped — the bot stopped responding despite being internally functional.Production logs (May 17–18, 2026)
A service restart immediately resolved the issue.
Root Cause
getCurrentDiagnosticPhase()returns whatever is on top ofactivePhaseStackwith no staleness check. Once a phase is pushed bywithDiagnosticPhase, it stays active until the wrapped promise resolves. For long-running tasks (channel polling loops, background sync processes), this means the phase is reported as "active" for the entire process lifetime.While #82592 fixed the specific case of Telegram by moving the trace to only cover the synchronous handoff, there is no safety net preventing other code paths from accidentally wrapping long-running tasks in diagnostic phases in the future.
Fix
Add a stale phase eviction mechanism to
getCurrentDiagnosticPhase():DIAGNOSTIC_PHASE_MAX_LIFETIME_MS) are automatically removed fromactivePhaseStackdetails.evicted = trueso they remain visible inrecentPhasesfor post-mortem analysisgetCurrentDiagnosticPhase()is called), adding zero overhead to normal operationThis is a defense-in-depth complement to #82592 — it prevents any future phase-tracking regression from causing the same 12+ hour degradation.
Files Changed
src/logging/diagnostic-phase.ts— addDIAGNOSTIC_PHASE_MAX_LIFETIME_MSconstant andevictStalePhases()functionsrc/logging/diagnostic-phase.test.ts— add test coverage for eviction behaviorEnvironment