Skip to content

chat.history leaks system-level memory injection blocks to WebChat UI #64613

Description

@JackChen201535

Describe the bug

The WebChat UI (macOS native app, Control UI) renders system-level memory injection blocks that should be invisible to users. These blocks contain internal prompts like:

## Memory system — ACTION REQUIRED

Auto-recall found no relevant results for a long query. You MUST call `memory_search` now with a shortened query (2-5 key words) before answering. Do not skip this step. Do NOT answer without searching first.

and

Read HEARTBEAT.md if it exists (workspace context). Follow it strictly. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.
When reading HEARTBEAT.md, use workspace file /Users/jackchen/.openclaw/workspace/HEARTBEAT.md (exact case). Do not read docs/heartbeat.md.

Expected behavior

These are internal system prompts injected for the agent, not user-facing content. The chat.history response should strip them before rendering to the UI.

The docs mention that chat.history strips inline delivery directives ([[reply_to_*]]), NO_REPLY, and tool-call XML, but memory/heartbeat system injection blocks are not currently filtered.

To reproduce

  1. Start a fresh session
  2. When auto-recall finds no relevant results, the system injects the memory search prompt
  3. The prompt appears visible in the WebChat UI

Environment

  • OpenClaw version: 2026.4.9 (0512059)
  • Platform: macOS (arm64)
  • Memory plugin: memos-local-openclaw-plugin
  • Channel: webchat (Control UI)

Suggested fix

Add filtering in chat.history for system injection blocks. These typically appear as:

  • ## Memory system — ACTION REQUIRED blocks
  • Heartbeat prompt blocks (starting with Read HEARTBEAT.md)

Similar to how [[reply_to_*]] and NO_REPLY are already stripped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions