Skip to content

[Bug]: [Bug]: ContextEngine afterTurn declares isHeartbeat but does not forward it #89302

@huangxun375-stack

Description

@huangxun375-stack

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

OpenClaw 2026.5.12 declares ContextEngine.afterTurn(params).isHeartbeat?: boolean, but observed afterTurn call sites do not pass isHeartbeat to context-engine plugins.

Steps to reproduce

  1. Start OpenClaw 2026.5.12 with a context-engine plugin enabled.
  2. Inspect the SDK type at dist/plugin-sdk/src/context-engine/types.d.ts.
  3. Inspect the runtime afterTurn call sites in dist/selection-61FIEezO.js and dist/attempt.tool-run-context-BuKiw0o1.js.
  4. Trigger a real heartbeat wake with openclaw system event --mode now --expect-final --text "test".
  5. Observe that the context-engine afterTurn call receives no top-level isHeartbeat field.

Expected behavior

For heartbeat runs, OpenClaw should pass isHeartbeat: true to contextEngine.afterTurn(...), matching the SDK type declaration.

Actual behavior

The SDK type declares isHeartbeat?: boolean, but the observed 2026.5.12 afterTurn call objects only pass sessionId, sessionKey, sessionFile, messages, prePromptMessageCount, tokenBudget, and runtimeContext.

Observed call sites:

  • dist/selection-61FIEezO.js:4793
  • dist/attempt.tool-run-context-BuKiw0o1.js:474

OpenClaw version

2026.5.12

Operating system

Windows 10.0.26200 x64

Install method

Local node_modules CLI, launched with openclaw.cmd gateway run

Model

doubao-seed-2.0-code

Provider / routing chain

NOT_ENOUGH_INFO

Additional provider/model setup details

NOT_ENOUGH_INFO

Logs, screenshots, and evidence

SDK type evidence:

`dist/plugin-sdk/src/context-engine/types.d.ts:215`


/** True when this turn belongs to a heartbeat run. */
isHeartbeat?: boolean;

Runtime call site 1:

dist/selection-61FIEezO.js:4793

await contextEngine.afterTurn({
  sessionId,
  sessionKey,
  sessionFile,
  messages: sourceMessages,
  prePromptMessageCount,
  tokenBudget,
  runtimeContext: params.getRuntimeContext?.(...)
});
Runtime call site 2:

dist/attempt.tool-run-context-BuKiw0o1.js:474

await params.contextEngine.afterTurn({
  sessionId: params.sessionIdUsed,
  sessionKey: params.sessionKey,
  sessionFile: params.sessionFile,
  messages: conversationSnapshot.messages,
  prePromptMessageCount: conversationSnapshot.prePromptMessageCount,
  tokenBudget: params.tokenBudget,
  runtimeContext: params.runtimeContext
});
E2E heartbeat wake evidence:

openclaw system event --mode now --expect-final --text "..." produced a heartbeat result:

{
  "status": "ok-token",
  "reason": "wake",
  "silent": true
}
The context-engine plugin stored heartbeat-related messages because no top-level isHeartbeat signal was observed by the plugin.


**Impact and severity**

Affected: Context-engine plugins that rely on `afterTurn(params).isHeartbeat` to skip heartbeat turns.
Severity: Data risk / memory pollution.
Frequency: Observed on OpenClaw 2026.5.12 afterTurn heartbeat wake path.
Consequence: Plugins cannot reliably distinguish heartbeat turns from normal turns via the documented top-level afterTurn field.

Impact and severity

No response

Additional information

The issue was observed with OpenViking as the active context-engine plugin. OpenViking has defensive code that checks afterTurnParams.isHeartbeat, but the field was not present in the observed 2026.5.12 afterTurn call path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingbug:behaviorIncorrect behavior without a crashclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions