openclaw - 💡(How to fix) Fix [Bug]: Telegram reply context captured in session JSONL but stripped from LLM context — agent cannot see replied message [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#73778Fetched 2026-04-29 06:15:19
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Timeline (top)
closed ×1commented ×1

Code Example

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

---

{
  "has_reply_context": true,
  "reply_to_id": "29436",
  "Replied message": {
    "sender_label": "J.A.R.V.I.S.",
    "body": "original message text..."
  }
}
RAW_BUFFERClick to expand / collapse

Bug Description

When a user replies to a message in Telegram (using the native reply/quote feature), the reply context data is correctly captured and stored in the session JSONL as a custom_message (openclaw.runtime-context), but it is stripped before reaching the LLM context.

The LLM only sees the runtime context header:

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

But the full content that exists in the session JSONL includes:

{
  "has_reply_context": true,
  "reply_to_id": "29436",
  "Replied message": {
    "sender_label": "J.A.R.V.I.S.",
    "body": "original message text..."
  }
}

This means the LLM agent cannot see what message the user is replying to, making it impossible to understand the context of follow-up questions.

Steps to Reproduce

  1. Have a Telegram conversation with the bot
  2. Use Telegram's native reply feature to reply to a previous message
  3. The bot agent cannot see the replied message content

Evidence

✅ Works: Session JSONL

The custom_message with customType: "openclaw.runtime-context" in the session JSONL contains the FULL Conversation info + Sender metadata + Replied message block, including has_reply_context: true, reply_to_id, and the complete body of the replied message.

❌ Broken: LLM Context

The same custom_message content, when assembled into the LLM context, is truncated to only the 2-line header. The Conversation info, Sender, and Replied message blocks are all stripped.

What We Tried

  1. Set channels.telegram.contextVisibility to "all" (from "allowlist_quote") — did NOT fix the issue
  2. Verified channels.telegram.replyToMode is set to "off" (this controls bot output reply behavior, not inbound context)

Environment

  • OpenClaw version: 2026.4.26
  • Channel: Telegram (direct message)
  • OS: Linux (Oracle Cloud VPS, arm64)

Impact

This is a critical feature for conversational context. Users who use Telegram's reply feature to reference previous messages cannot have their agent understand what they're referring to. The agent appears to "forget" or "ignore" the reply context.

Related Issues

  • This is similar to issues reported for other channels (#10872 for iMessage, #42266 for iMessage)

Proposed Fix Direction

The stripping likely occurs in the LLM context assembly pipeline, possibly in how custom_message content is projected into the LLM prompt. The metadata blocks (Conversation info, Sender, Replied message) should be preserved when building the LLM context, not stripped as "internal details."

extent analysis

TL;DR

The LLM context assembly pipeline likely strips the reply context metadata, preventing the agent from understanding the conversation context.

Guidance

  • Investigate the LLM context assembly pipeline to identify where the custom_message content is being stripped, focusing on how metadata blocks are projected into the LLM prompt.
  • Verify that the custom_message content in the session JSONL is correctly formatted and contains all necessary metadata, including has_reply_context, reply_to_id, and the Replied message block.
  • Check the OpenClaw documentation for any settings or configuration options that control the LLM context assembly pipeline, such as filtering or sanitization rules that might be stripping the metadata.
  • Consider modifying the LLM context assembly pipeline to preserve the metadata blocks, potentially by adjusting the projection logic or adding custom handling for custom_message content.

Example

No code snippet is provided, as the issue is more related to configuration and pipeline processing.

Notes

The issue seems to be specific to the LLM context assembly pipeline and how it handles custom_message content. The fact that the session JSONL contains the full conversation info and metadata suggests that the issue is not with data capture, but rather with how that data is processed and presented to the LLM.

Recommendation

Apply a workaround by modifying the LLM context assembly pipeline to preserve the metadata blocks, as this is likely to be a more targeted and effective solution than attempting to upgrade or change the OpenClaw version.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: Telegram reply context captured in session JSONL but stripped from LLM context — agent cannot see replied message [1 comments, 2 participants]