Skip to content

[Bug]: Telegram runtime context metadata leak — <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>> visible in every turn #108284

Closed

Description

@sunnyaiassistant

Summary

The runtime context injection feature (introduced in v2026.7.0+) is leaking the full <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>> block into Telegram chat replies. This includes:

  • Full conversation history being re-injected every turn (previous messages, session tool calls)
  • The block appearing literally in my streamed replies to the user
  • Making the session unusable — every reply contains a wall of metadata and history

Steps to reproduce

  1. Install OpenClaw v2026.7.1
  2. Start a Telegram DM conversation
  3. After a few exchanges, the runtime context block appears in respones
  4. The block grows with each turn as it accumulates

Expected behavior

The <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>> block should be stripped before being passed to the model, or at minimum before being delivered to the user. Same pattern as Feishu bug #96921 which was fixed for Feishu but not Telegram.

Environment

  • OpenClaw: 2026.7.1
  • Channel: Telegram (DM)
  • Model: deepseek/deepseek-v4-flash (primary deepseek/deepseek-v4-pro)
  • Node: v24.18.0 (macOS)

Activity

  1. added
    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.
    impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.
    on Jul 16, 2026
  2. clawsweeper commented on Jul 16, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 15, 2026, 11:12 PM ET / July 16, 2026, 03:12 UTC.

    Summary
    Keep open: the report describes a severe, release-current Telegram regression, and current main has a central sanitizer that should remove this exact delimiter, but the evidence does not yet isolate whether Telegram streaming previews, inbound replay, or another projection bypasses that sanitizer. No merged fix or canonical replacement currently owns this Telegram-specific failure. (github.com)

    Reproducibility: no. not yet at high confidence on current main. The release-specific steps are credible, but current main's final-text sanitizer already strips the reported delimiter, so a live Telegram trace is needed to identify the bypassing preview, ingress, or replay path.

    Ways to help us reproduce this

    • Add expected vs actual behavior.
    • Include redacted logs or terminal output.

    Next step
    The issue is security-sensitive and the bypass boundary is not yet isolated, so it should receive maintainer-led reproduction rather than an automatic repair attempt.

    Security
    Needs attention: The issue plausibly exposes sensitive runtime and session metadata in Telegram, but the affected trust boundary and exact delivery path still need confirmation.

    Review details

    Best possible solution:

    Keep runtime context structured and model-visible, but route every Telegram preview and final reply through one shared user-visible sanitizer; add mixed-wrapper and wrapper-only regression coverage, and provide an in-product chat reset action if contaminated session state survives the fix.

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

    No, not yet at high confidence on current main. The release-specific steps are credible, but current main's final-text sanitizer already strips the reported delimiter, so a live Telegram trace is needed to identify the bypassing preview, ingress, or replay path.

    Is this the best way to solve the issue?

    No, stripping the block before it reaches the model is not the best general fix because runtime context is intentionally model-facing. The maintainable fix is to preserve structured internal context while sanitizing every user-visible streaming and final-delivery projection through one canonical boundary.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The exact current-main escape path is not isolated: Telegram preview streaming, inbound replay, provider transcript projection, and final delivery require separate checks.
    • No current-main live Telegram transcript, recording, or sanitized gateway trace was available to distinguish model echo from channel-side re-injection.
    • The visible block may contain conversation history, identifiers, and tool details; even if exposure is limited to the current chat, the sensitive-data scope needs confirmation.

    Codex review notes: model internal, reasoning high; reviewed against 957cc81175a3.

    Label changes

    Label changes:

    • add P0: The report says every Telegram reply becomes an unusable wall of internal metadata, with no in-product recovery path described.
    • add impact:security: Conversation history, identifiers, and session tool details are reportedly exposed in a user-visible channel message.
    • add impact:session-state: The internal context is reportedly re-injected and grows on each turn, indicating transcript or runtime-context state is feeding back into later turns.
    • add impact:ux-release-blocker: A normal Telegram user cannot continue the conversation once every reply is dominated by internal context, and recovery currently lacks a visible product control.
    • add issue-rating: 🦐 gold shrimp: Current issue advisory state selects this label.
    • add clawsweeper:needs-info: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
    • add clawsweeper:needs-security-review: Current issue advisory state selects this label.

    Label justifications:

    • P0: The report says every Telegram reply becomes an unusable wall of internal metadata, with no in-product recovery path described.
    • impact:ux-release-blocker: A normal Telegram user cannot continue the conversation once every reply is dominated by internal context, and recovery currently lacks a visible product control.
    • impact:session-state: The internal context is reportedly re-injected and grows on each turn, indicating transcript or runtime-context state is feeding back into later turns.
    • impact:security: Conversation history, identifiers, and session tool details are reportedly exposed in a user-visible channel message.
    Evidence reviewed

    Security concerns:

    • [medium] Internal session context may be disclosed in chat
      The reported wrapper contains conversation history, identifiers, and tool-call details that are intended to remain internal; a live trace should establish whether any data can reach unintended channel participants.
      Confidence: 0.78

    What I checked:

    Likely related people:

    • joshavant: Authored and merged the central outbound payload-normalization work that owns shared delivery projection semantics relevant to preventing channel-visible internal text. (github.com) (role: outbound normalization owner; confidence: high; commits: c476409; files: src/infra/outbound/payloads.ts, src/infra/outbound/deliver.ts)
    • steipete: Recent history connects this contributor to runtime-context prompt placement and keeping internal/runtime events out of visible turns, making them relevant to the model/session side of the boundary. (role: recent runtime-context contributor; confidence: medium; commits: 7e0e29ef1749, 6df120fb3987, 11e6928b3edc; files: src/agents/pi-embedded-runner/run/runtime-context-prompt.ts, src/agents/internal-runtime-context.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.
  3. steipete commented on Jul 29, 2026

    @steipete
    Contributor

    Thanks for the concrete Telegram reproduction. This is fixed on main by PR #115561, #115561, landed as f849080. The fix is in the shared outbound delivery owner, before a channel adapter receives the assistant payload, so a complete inline internal runtime-context block is removed for every channel rather than adding a Telegram-only workaround. Standalone canonical context handling, ordinary user text that mentions a single marker, escaped nested metadata, and extra closing-marker collisions remain protected. Before-fix reproduction is https://github.com/openclaw/openclaw/actions/runs/30420240724. Exact-head proof is 238 passing real outbound-adapter, delivery queue, channel contract, sanitizer, and runtime-context tests in https://github.com/openclaw/openclaw/actions/runs/30422340930; full changed-gate evidence is https://github.com/openclaw/openclaw/actions/runs/30421706284 and exact-head GitHub CI is https://github.com/openclaw/openclaw/actions/runs/30422727996. Closing as fixed on main alongside #113754. If a tagged release containing this commit still displays a complete runtime-context block in a Telegram reply, please open a new report with the exact release, redacted output, and delivery route.

  4. locked as resolved and limited conversation to collaborators on Oct 6, 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

    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.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.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions