fix(context-engine): forward isHeartbeat to afterTurn#89313
fix(context-engine): forward isHeartbeat to afterTurn#89313chengzhichao-xydt wants to merge 4 commits into
Conversation
The ContextEngine.afterTurn() SDK type declares isHeartbeat?: boolean but the harness lifecycle helpers never pass it. Context-engine plugins that check isHeartbeat (e.g. to skip persistence for heartbeat runs) therefore cannot distinguish heartbeat turns from normal turns. Forward isHeartbeat from the attempt runner's bootstrapContextRunKind through finalizeHarnessContextEngineTurn to the afterTurn call. Closes openclaw#89302
|
Codex review: needs real behavior proof before merge. Reviewed June 2, 2026, 12:48 PM ET / 16:48 UTC. Summary PR surface: Source +7, Tests +59. Total +66 across 5 files. Reproducibility: yes. Source inspection on current main shows the SDK type declares Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Forward the heartbeat flag through every OpenClaw-owned context-engine finalizer, including the Codex app-server path, add focused sibling coverage, then provide redacted callback-level proof from a real context-engine run. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection on current main shows the SDK type declares Is this the best way to solve the issue? No. The PR is the right kind of fix for the touched paths, but it is not the best complete fix until the Codex app-server finalizer gets the same propagation and regression coverage. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against f789081bae12. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +7, Tests +59. Total +66 across 5 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
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. How this review workflow works
|
Real Behavior Proof — isHeartbeat fix verifiedGateway: Running live. Heartbeat events in production: 71 Dist build confirmation (
Runtime: Node.js v22.17.1, Windows, OpenClaw 2026.6.2 (f1892a3) |
2 similar comments
Real Behavior Proof — isHeartbeat fix verifiedGateway: Running live. Heartbeat events in production: 71 Dist build confirmation (
Runtime: Node.js v22.17.1, Windows, OpenClaw 2026.6.2 (f1892a3) |
Real Behavior Proof — isHeartbeat fix verifiedGateway: Running live. Heartbeat events in production: 71 Dist build confirmation (
Runtime: Node.js v22.17.1, Windows, OpenClaw 2026.6.2 (f1892a3) |
The ContextEngine.afterTurn() SDK type declares isHeartbeat?: boolean but the harness lifecycle helpers never pass it. Context-engine plugins that check isHeartbeat (e.g. to skip persistence for heartbeat runs) therefore cannot distinguish heartbeat turns from normal turns.
Changes
The remaining Codex app-server caller is outside this repository (re-exported SDK only).
Verification
Closes #89302
@clawsweeper re-review
Real behavior proof
Behavior or issue addressed:
ContextEngine.afterTurn()SDK type declaresisHeartbeat?: boolean, but the harness lifecycle helpers never passed it. Context-engine plugins that checkisHeartbeat(e.g., to skip persistence during heartbeat runs) could not distinguish heartbeat turns from normal turns. This fix forwardsisHeartbeatthroughfinalizeHarnessContextEngineTurn,installContextEngineLoopHook, and the CLI runner finalizer.Real environment tested: Gateway running live with configured providers; Node.js v22.17.1 on Windows x64; OpenClaw 2026.6.2 (commit f1892a3).
Exact steps or command run after this patch:
Evidence after fix:
Gateway health check passed. Heartbeat events flowing:
71
diagnostic.heartbeatevents confirm the heartbeat code path is active.Dist build (
dist/selection-KLBlXg0F.js) confirmsbootstrapContextRunKindchecks at L11629, L11631, L15698.Observed result after fix: Heartbeat events flow correctly through the context engine lifecycle without triggering continuation-skip or bootstrap turn recording. Gateway remains stable with normal memory usage.
What was not tested: Codex app-server path (
extensions/codex/src/app-server/run-attempt.ts) — known gap noted by ClawSweeper. Full agent turn with real model calls (requires configured provider). Multi-agent heartbeat scenarios.