Skip to content

[Bug]: Telegram forum topic names are not reliably included in agent context #86024

Closed

Description

@ralphkrauss

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Telegram forum topic names are not reliably included in agent context, so agents can receive only a message_thread_id/topic id and block even when the topic title is the intended task context.

Steps to reproduce

  1. Run OpenClaw 2026.5.19 with the Telegram provider connected to a forum-enabled Telegram supergroup and routed agent.
  2. Use a forum topic whose title is needed as workflow context.
  3. Send a topic-scoped native command or routed request that relies on the current Telegram topic title, without also typing the issue number or branch/topic name in the message body.
  4. Inspect the resulting agent session/trajectory.

Observed local evidence, with project-specific identifiers intentionally redacted:

  • OpenClaw version: OpenClaw 2026.5.19 (a185ca2).
  • The session key shape included a Telegram group topic id.
  • The agent trajectory trusted metadata for that turn included Telegram channel/provider/chat type but no topic_name.
  • The agent replied that OpenClaw only provided the Telegram topic id, not the topic title, so it could not safely infer the intended issue/branch.
  • The local topic-name cache had a matching title for the same redacted group/topic key.

Expected behavior

When OpenClaw has, creates, edits, or observes a Telegram forum topic title, agent turns in that topic should include both the topic id and topic name in trusted metadata before prompt construction. This should work for normal topic messages, native slash commands, and system/wakeup turns that reconstruct delivery context from session state.

Actual behavior

The agent can receive only the topic id/thread id, with no trusted topic_name, and then asks the user for an issue/branch/topic name even though the current Telegram topic title is the intended context.

OpenClaw version

2026.5.19 (a185ca2)

Operating system

Ubuntu 24.04

Install method

npm global under nvm, launched via systemd user service

Model

openai/gpt-5.5 (not model-specific)

Provider / routing chain

Telegram group topic -> OpenClaw gateway -> routed OpenClaw agent -> OpenAI provider

Additional provider/model setup details

The behavior is in Telegram channel metadata/session context before model execution. No provider-specific behavior is required to reproduce.

Logs, screenshots, and evidence

$ openclaw --version
OpenClaw 2026.5.19 (a185ca2)

Redacted local evidence:
- A Telegram forum-topic session had a topic-scoped session key.
- The agent-visible trusted metadata did not include topic_name.
- The agent response stated that only the Telegram topic id was available.
- The local topic-name cache had a matching title for the same redacted group/topic key.

Impact and severity

Affected: Telegram forum-topic users who use topic names as workflow context, especially issue/topic workflows.

Severity: Medium to high for mobile workflows. It blocks otherwise valid commands unless the user redundantly types the issue number or branch/topic name in the message body.

Frequency: Observed when the agent turn receives only the Telegram topic id in metadata, including native command/topic flows.

Consequence: Agents ask for clarification instead of starting the requested work, even though the Telegram topic title is the intended source of truth.

Additional information

This seems difficult to solve cleanly as an external plugin today because the available message hooks appear observational for this path; they do not provide a supported way to mutate trusted inbound context before prompt construction.

A robust core fix would likely:

  • persist topic names from Telegram forum_topic_created and forum_topic_edited service messages;
  • persist topic names immediately after successful createForumTopic and editForumTopic actions;
  • resolve cached topic names into TopicName for normal inbound messages, native slash commands, and system/wakeup turns;
  • include tests that verify topic_name survives all three paths.

Activity

  1. clawsweeper commented on May 24, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

    Latest ClawSweeper review: 2026-05-24 11:20 UTC / May 24, 2026, 7:20 AM ET.

    Workflow note: Future ClawSweeper reviews update this same comment in place.

    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.

    Summary
    Keep open: current main partially covers normal Telegram inbound messages, but source inspection still shows missing topic-name propagation for native slash-command context, topic create/edit actions, and reconstructed delivery/system turns.

    Reproducibility: yes. at source level: current main builds native Telegram command and restart-continuation contexts with MessageThreadId but without TopicName, while the normal inbound path has a cache-backed TopicName flow. I did not run live Telegram because this review is read-only.

    Next step
    The source gaps are concrete and bounded to Telegram context propagation, with clear tests to extend.

    Review details

    Best possible solution:

    Keep the fix in the Telegram channel boundary by making one canonical topic-name resolver/cache update path feed normal inbound, native command, successful create/edit, and reconstructed system delivery contexts.

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

    Yes, at source level: current main builds native Telegram command and restart-continuation contexts with MessageThreadId but without TopicName, while the normal inbound path has a cache-backed TopicName flow. I did not run live Telegram because this review is read-only.

    Is this the best way to solve the issue?

    Yes: extending the existing Telegram topic-name cache/resolver across the missing Telegram-owned paths is narrower and more maintainable than adding a core workaround or external plugin hook.

    Label changes:

    • add P2: The bug blocks topic-scoped Telegram workflows that rely on topic titles, but the blast radius is limited to Telegram forum-topic context propagation.
    • add impact:session-state: The missing topic name is trusted conversation/session context that should survive routing and prompt construction.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

    Label justifications:

    • P2: The bug blocks topic-scoped Telegram workflows that rely on topic titles, but the blast radius is limited to Telegram forum-topic context propagation.
    • impact:session-state: The missing topic name is trusted conversation/session context that should survive routing and prompt construction.

    Acceptance criteria:

    • node scripts/run-vitest.mjs extensions/telegram/src/bot-message-context.dm-threads.test.ts
    • node scripts/run-vitest.mjs extensions/telegram/src/bot-native-commands.session-meta.test.ts extensions/telegram/src/action-runtime.test.ts extensions/telegram/src/bot-message-dispatch.test.ts src/auto-reply/reply/inbound-meta.test.ts

    What I checked:

    • Current main has partial normal-message support: Forum inbound messages resolve a persisted topic-name cache from service-message fields and reply_to_message forum metadata, then pass topicName into the Telegram inbound context builder. (extensions/telegram/src/bot-message-context.ts:175, 578e73f66763)
    • Prompt metadata supports the expected field: The inbound context type exposes TopicName and prompt metadata maps it to topic_name, so the expected trusted metadata field already exists for paths that populate TopicName. (src/auto-reply/reply/inbound-meta.ts:504, 578e73f66763)
    • Native slash commands still omit TopicName: Native command context construction includes MessageThreadId and IsForum but has no TopicName lookup or assignment before finalizeInboundContext, so a topic-scoped native command can enter prompt construction with only the topic id. (extensions/telegram/src/bot-native-commands.ts:1151, 578e73f66763)
    • Topic create/edit actions do not update the topic-name cache: createForumTopic and editForumTopic return the topic name/result to the tool caller, but the only production updateTopicName use found is in bot-message-context, not after successful create/edit actions. (extensions/telegram/src/action-runtime.ts:721, 578e73f66763)
    • Recovered dispatch context restores ids but not names: resolveDispatchTelegramContext recovers MessageThreadId, OriginatingTo, To, TransportThreadId, history, and body from a topic-scoped session key, but does not recover or populate TopicName. (extensions/telegram/src/bot-message-dispatch.ts:651, 578e73f66763)
    • Restart/system continuation context lacks topic names: server restart continuation rebuilds a trusted inbound context from the stored route with MessageThreadId but no TopicName, matching the reported system/wakeup gap. (src/gateway/server-restart-sentinel.ts:308, 578e73f66763)

    Likely related people:

    • ptahdunbar: The merged topic-name context work was credited to this handle in the 8c43768 commit message and added the cache, TopicName context field, topic_name prompt metadata, and tests. (role: introduced topic-name behavior; confidence: high; commits: 8c43768e27b0; files: extensions/telegram/src/bot-message-context.ts, extensions/telegram/src/topic-name-cache.ts, src/auto-reply/reply/inbound-meta.ts)
    • obviyus: Ayaan Zaidi co-authored the original topic-name PR and authored the follow-up commits that persisted the topic-name cache through the default runtime path. (role: topic-cache persistence contributor; confidence: high; commits: c91d3d4537f3, ad181b2361ba, 4f92b1fbb0b5; files: extensions/telegram/src/bot-message-context.ts, extensions/telegram/src/topic-name-cache.ts, extensions/telegram/src/bot-message-context.dm-threads.test.ts)
    • Josh Lehman: The most recent topic dispatch recovery work in 62b51a6 rewrites Telegram forum thread context during dispatch and is directly adjacent to the reconstructed-context part of this issue. (role: recent topic-dispatch contributor; confidence: medium; commits: 62b51a6295ee; files: extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/bot-message-dispatch.test.ts)
    • Gio Della-Libera: Recent current-line blame for Telegram native command context and restart-continuation context points to 068b9ac, which touched adjacent gateway/Telegram context construction paths. (role: recent adjacent contributor; confidence: medium; commits: 068b9acb51e0; files: extensions/telegram/src/bot-native-commands.ts, src/gateway/server-restart-sentinel.ts, extensions/telegram/src/bot-message-context.ts)

    Remaining risk / open question:

    • I did not run a live Telegram forum supergroup reproduction in this read-only review; the keep-open decision is based on current-main source paths.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 578e73f66763.

  2. added
    P2Normal backlog priority with limited blast radius.
    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.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    on May 24, 2026
  3. added a commit that references this issue on May 25, 2026
    5182ebc
  4. added a commit that references this issue on May 26, 2026
    eafb03a
  5. locked as resolved and limited conversation to collaborators on May 28, 2026
  6. added a commit that references this issue on Jun 2, 2026
    3c99f50
  7. added a commit that references this issue on Jun 10, 2026
    f0f7314
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: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

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions