Skip to content

Inbound system event rendered twice per turn (runtime-context message + reply-body prepend) on Slack #95323

Closed

Description

@gorkem2020

Summary

On Slack, a single inbound system event is rendered twice in one assembled turn. The notification header System: [timestamp] Slack DM from <user> appears both inside an OpenClaw runtime context for the immediately preceding user message wrapper and again standalone just before the raw user text, with the same timestamp and the same label. The user body itself is delivered once; it is the system-event header that is duplicated.

This is distinct from the preview fix in #94549 / #94589. That change removed the 160-character body preview from the enqueued system event, so each header is now notification-only. It did not change how many times the event is rendered. Before that fix each of the two copies carried the truncated preview (so a message appeared three times: two previews plus the raw body); after it, the two copies are label-only, but there are still two of them. Removing the duplicate rendering was out of scope for that PR.

Environment

OpenClaw 2026.6.1, Linux, Node 24. Channel: Slack (first-party @openclaw/slack), direct message.

Reproduction

  1. Send any inbound message from Slack.
  2. Capture the model-facing request (the provider payload).
  3. Observe the same System: header in two separate messages of the same turn.

Evidence (redacted model-facing payload, one turn)

Two adjacent messages in the same request, identical timestamp:

Message A (a standalone runtime-context message immediately preceding the user turn):

OpenClaw runtime context for the immediately preceding user message.
This context is runtime-generated, not user-authored. Keep internal details private.

System: [2026-06-20 13:59:51] Slack DM from <user>

Message B (the user message itself, header prepended before the raw text):

Conversation info (untrusted metadata):
{ ...redacted... }

Sender (untrusted metadata):
{ ...redacted... }

System: [2026-06-20 13:59:51] Slack DM from <user>

<the actual user text>

Both System: lines carry the same timestamp, confirming this is one event rendered twice in a single turn, not conversation-history replay (which would differ in timestamp) and not a second model call.

Channel contrast

A Telegram direct message in the same setup produces no System: header at all: the Telegram inbound path does not enqueue an inbound system event, so the user message arrives bare (no header, no metadata wrapper). The duplication is specific to channels that enqueue an inbound system event, which Slack does.

Likely area (hypothesis, for maintainer confirmation)

The two render sites appear to be:

  1. The runtime-context split that extracts runtime-generated context into a separate OpenClaw runtime context for the immediately preceding user message message.
  2. The reply-body assembly that prepends the drained system-event block into the user prompt body.

The drained inbound system event seems to be carried by both paths in the same turn, so the header is both extracted into the runtime-context message and left prepended in the body, rather than appearing once. Maintainers can confirm the exact flow.

Impact

Low severity, no data loss. The body is intact and the header is label-only since #94589, so this is a small amount of duplicated metadata per inbound turn: a redundant context block, a few wasted tokens, and a slightly inconsistent turn structure presented to the model. It is most visible on channels that enqueue inbound system events, and it compounds visually in busy multi-party Slack conversations.

Activity

  1. clawsweeper commented on Jun 20, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 9:39 AM ET / 13:39 UTC.

    Summary
    Keep open. Current main still has the source shape that can render the same Slack inbound system-event label in both runtime context and the model-facing user body, and an open closing PR already owns the candidate fix.

    Reproducibility: Do we have a high-confidence way to reproduce the issue? Medium source confidence: current main shows the Slack event entering the prompt pipeline and the runtime splitter can leave the same label in the model prompt, but I did not run a live Slack provider-payload capture.

    Root-cause cluster
    Relationship: canonical
    Canonical: #95323
    Summary: This issue is the canonical report for the Slack duplicate system-event label; the main viable implementation path is the open runtime-context/modelPrompt fix PR.

    Members:

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

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.

    Next step
    This issue already has an open closing PR, so the next action is to review and land or close that PR rather than queue a second repair job.

    Review details

    Best possible solution:

    Review and land or decline #95349; if it lands, this issue can close as implemented by that runtime-context/modelPrompt fix.

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

    Do we have a high-confidence way to reproduce the issue? Medium source confidence: current main shows the Slack event entering the prompt pipeline and the runtime splitter can leave the same label in the model prompt, but I did not run a live Slack provider-payload capture.

    Is this the best way to solve the issue?

    Is this the best way to solve the issue? Yes: the narrow maintainable path is the existing runtime-context/modelPrompt split fix or equivalent model-boundary repair, not removing Slack's label-only enqueue or losing drained events across refresh.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • No live Slack provider-payload capture was run in this read-only pass; the keep-open decision is based on the issue payload, current source trace, and the open candidate PR's focused proof.

    Codex review notes: model internal, reasoning high; reviewed against 11a2e03bd4de.

    Label changes

    Label changes:

    • add clawsweeper:linked-pr-open: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.

    Label justifications:

    • P2: The report describes a normal-priority Slack prompt correctness bug with limited channel blast radius.
    • impact:message-loss: The issue is about duplicated model-visible inbound channel metadata in Slack turns.
    Evidence reviewed

    What I checked:

    • Repository policy read: Root AGENTS.md and scoped guides for agents, embedded runner, and extensions were read; their deep-review and prompt-helper guidance affected the decision. (AGENTS.md:10, 11a2e03bd4de)
    • Vision fit: VISION.md lists bug fixes, stability, and improving major messaging channels as priorities, so this Slack prompt-correctness issue fits the repo direction. (VISION.md:14, 11a2e03bd4de)
    • Slack still enqueues the label-only inbound event: Slack direct messages still enqueue Slack DM from ... as a system event with a Slack message context key; the preview fix did not remove this event from the prompt pipeline. (extensions/slack/src/monitor/message-handler/prepare.ts:1134, 11a2e03bd4de)
    • System events become model-visible System lines: drainFormattedSystemEvents consumes queued entries and formats them as System: [timestamp] ..., matching the duplicated header form in the report. (src/auto-reply/reply/session-system-events.ts:103, 11a2e03bd4de)
    • Reply prompt assembly prepends drained events: buildReplyPromptBodies joins systemEventBlocks and prepends them to the effective and queued body paths while keeping transcript text separate. (src/auto-reply/reply/prompt-prelude.ts:38, 11a2e03bd4de)
    • Reply run carries drained events into queued body: get-reply-run drains system events, stores them in drainedSystemEventBlocks, and passes them into buildReplyPromptEnvelope, which keeps the event-prefixed body on the model path. (src/auto-reply/reply/get-reply-run.ts:803, 11a2e03bd4de)

    Likely related people:

    • vincentkoc: Current blame for the central splitter, attempt caller, reply drain, and Slack enqueue lines points at recent imported main commits by Vincent Koc, and path history shows recent runtime/context work by the same author. (role: recent runtime-context contributor; confidence: high; commits: 61d1fd1f7217, c645ec4555c0, 74e7b8d47b18; files: src/agents/embedded-agent-runner/run/runtime-context-prompt.ts, src/agents/embedded-agent-runner/run/attempt.ts, src/auto-reply/reply/get-reply-run.ts)
    • steipete: Recent file history shows repeated Slack inbound context and auto-reply prompt work, plus refresh commits on the adjacent preview-removal PR. (role: recent prompt and Slack context contributor; confidence: medium; commits: e6c1e9c64bc5, 6b525023d4d2, 981003591c99; files: extensions/slack/src/monitor/message-handler/prepare.ts, src/auto-reply/reply/prompt-prelude.ts, src/auto-reply/reply/session-system-events.ts)
    • hugenshen: Authored the merged Slack/Teams preview-removal work that this issue explicitly distinguishes from the remaining label-only double-render problem. (role: adjacent prior fix author; confidence: medium; commits: 041790eb1e78, 47545e04c4bd; files: extensions/slack/src/monitor/message-handler/prepare.ts, extensions/slack/src/monitor/message-handler/prepare.test.ts, extensions/msteams/src/monitor-handler/message-handler.ts)
    • openperf: Authored the open closing PR that targets the runtime-context/modelPrompt split and includes focused regression coverage for this exact issue. (role: canonical candidate fix author; confidence: medium; commits: 6eda65e8d897; files: src/agents/embedded-agent-runner/run/runtime-context-prompt.ts, src/agents/embedded-agent-runner/run/runtime-context-prompt.test.ts, src/agents/embedded-agent-runner/run/attempt.llm-boundary.test.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P2Normal backlog priority with limited blast radius.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    on Jun 20, 2026
  3. added
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    on Jun 21, 2026
  4. added a commit that references this issue on Jun 25, 2026
    0c749d9
  5. gorkem2020 commented on Jun 27, 2026

    @gorkem2020
    ContributorAuthor

    Live repro on 2026.6.10 (Slack DM). Posting for the needs-live-repro label.

    For a single inbound Slack DM turn, the model-facing prompt contains the System: [<ts>] Slack DM from <sender> wrapper line twice:

    1. inside the <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>> runtime-context block (next to the OpenClaw runtime context for the immediately preceding user message. header, which appears once), and
    2. inside the decorated inbound user message that immediately follows.

    Expected: the wrapper line appears once per turn.
    Actual: it appears twice.

    Confirmed on a clean 2026.6.10 build (core + @openclaw/slack 2026.6.10). The merged body-preview removal (#94589) stripped the body preview but not this wrapper-line duplication. Cosmetic in isolation, but it duplicates the inbound metadata line every Slack turn and compounds across agents sharing a channel.

  6. locked as resolved and limited conversation to collaborators on Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions