Summary
Sub-agent / agent-to-agent announce delivery can lose the originating thread/topic when the announce target is resolved via sessions.list fallback.
This causes completion messages to land in the parent channel top-level instead of the originating Telegram forum topic / thread.
Affected path
The regression is in the legacy A2A announce flow:
src/agents/tools/sessions-announce-target.ts
src/agents/tools/sessions-send-tool.a2a.ts
Root cause
resolveAnnounceTarget() falls back to sessions.list when the channel/plugin prefers session lookup.
- In that branch it hydrates
channel, to, and accountId, but drops threadId even when it exists in:
deliveryContext.threadId
- or
match.lastThreadId
runSessionsSendA2AFlow() then calls gateway send without threadId.
So the announce still knows the chat target, but loses the thread/topic target.
Repro
- Start from a threaded/topic conversation (for example Telegram forum topic).
- Trigger a flow that returns through the legacy A2A announce path.
- Wait for the sub-agent / delegated response to announce back.
- Observe the final announce is delivered to the channel top-level instead of the originating thread/topic.
Expected
When thread/topic context exists in session delivery metadata, the announce target should preserve it and the final send should include threadId.
Actual
threadId is dropped during target resolution and never sent.
Related
This appears to be in the same family as:
But this issue is narrower and specifically covers the legacy sessions_send A2A announce path dropping threadId on sessions.list fallback.
Proposed fix
- In
resolveAnnounceTarget(), preserve threadId from deliveryContext.threadId or match.lastThreadId.
- In
runSessionsSendA2AFlow(), pass threadId into the final gateway send call when present.
- Add regression tests covering both behaviors.
Summary
Sub-agent / agent-to-agent announce delivery can lose the originating thread/topic when the announce target is resolved via
sessions.listfallback.This causes completion messages to land in the parent channel top-level instead of the originating Telegram forum topic / thread.
Affected path
The regression is in the legacy A2A announce flow:
src/agents/tools/sessions-announce-target.tssrc/agents/tools/sessions-send-tool.a2a.tsRoot cause
resolveAnnounceTarget()falls back tosessions.listwhen the channel/plugin prefers session lookup.channel,to, andaccountId, but dropsthreadIdeven when it exists in:deliveryContext.threadIdmatch.lastThreadIdrunSessionsSendA2AFlow()then calls gatewaysendwithoutthreadId.So the announce still knows the chat target, but loses the thread/topic target.
Repro
Expected
When thread/topic context exists in session delivery metadata, the announce target should preserve it and the final
sendshould includethreadId.Actual
threadIdis dropped during target resolution and never sent.Related
This appears to be in the same family as:
announceTargetoption for sub-agent completion announce routing #27445But this issue is narrower and specifically covers the legacy
sessions_sendA2A announce path droppingthreadIdonsessions.listfallback.Proposed fix
resolveAnnounceTarget(), preservethreadIdfromdeliveryContext.threadIdormatch.lastThreadId.runSessionsSendA2AFlow(), passthreadIdinto the final gatewaysendcall when present.