Skip to content

bug: sessions_send A2A announce drops threadId on sessions.list fallback #63469

@irispillars

Description

@irispillars

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

  1. resolveAnnounceTarget() falls back to sessions.list when the channel/plugin prefers session lookup.
  2. In that branch it hydrates channel, to, and accountId, but drops threadId even when it exists in:
    • deliveryContext.threadId
    • or match.lastThreadId
  3. runSessionsSendA2AFlow() then calls gateway send without threadId.

So the announce still knows the chat target, but loses the thread/topic target.

Repro

  1. Start from a threaded/topic conversation (for example Telegram forum topic).
  2. Trigger a flow that returns through the legacy A2A announce path.
  3. Wait for the sub-agent / delegated response to announce back.
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions