Skip to content

fix(announce): preserve threadId in subagent announce for Telegram DM topics#52824

Draft
Lukavyi wants to merge 1 commit intoopenclaw:mainfrom
Lukavyi:fix/topic-announce-threadid
Draft

fix(announce): preserve threadId in subagent announce for Telegram DM topics#52824
Lukavyi wants to merge 1 commit intoopenclaw:mainfrom
Lukavyi:fix/topic-announce-threadid

Conversation

@Lukavyi
Copy link
Copy Markdown
Contributor

@Lukavyi Lukavyi commented Mar 23, 2026

Summary

Fixes #52217 — subagent completion announce was delivering to the main Telegram DM chat instead of the originating topic because threadId was lost during the announce delivery pipeline.

  • Swap conversationId priority in resolveSubagentCompletionOrigin: prefer to-derived chat ID over threadId for bound-route lookups, so bindings match the conversation (chat) rather than the topic thread inside it
  • Defensive threadId guard in resolveAnnounceOrigin: ensure the requester's threadId (captured at spawn time) is never overridden by a stale session entry lastThreadId
  • Telegram observability: add message_thread_id to sendMessage ok log lines for easier diagnosis
  • 3 regression tests: direct path (no entry threadId), queue path (stale entry threadId), and no-spurious-injection scenario

Test plan

  • pnpm test -- src/agents/subagent-announce.format.e2e.test.ts — 73 tests pass (including 3 new)
  • pnpm test -- src/utils/delivery-context.test.ts — 9 tests pass
  • pnpm check — all lint/format checks pass
  • Manual: spawn subagent from Telegram DM topic, verify completion announce lands in the same topic

… topics (openclaw#52217)

Two fixes to prevent threadId loss during subagent announce delivery:

1. Swap conversationId priority in resolveSubagentCompletionOrigin to prefer
   the chat-level ID from `to` over threadId, so bound-route lookups match
   the conversation rather than the topic thread inside it.

2. Add defensive guard in resolveAnnounceOrigin ensuring the requester's
   threadId (captured at spawn) is never overridden by a stale session
   entry threadId during the merge.

Also adds message_thread_id to Telegram sendMessage log lines for
observability, and three regression tests covering direct, queue, and
no-thread scenarios.

Closes openclaw#52217
@openclaw-barnacle openclaw-barnacle bot added channel: telegram Channel integration: telegram agents Agent runtime and tooling size: S labels Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: telegram Channel integration: telegram size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Subagent announce delivers to wrong Telegram DM topic (stale threadId)

1 participant