Skip to content

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

Open
BingqingLyu wants to merge 1 commit intomainfrom
fork-pr-52824-fix-topic-announce-threadid
Open

fix(announce): preserve threadId in subagent announce for Telegram DM topics#1269
BingqingLyu wants to merge 1 commit intomainfrom
fork-pr-52824-fix-topic-announce-threadid

Conversation

@BingqingLyu
Copy link
Copy Markdown
Owner

@BingqingLyu BingqingLyu commented Apr 27, 2026

Summary

Fixes openclaw#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants