Skip to content

Bug: Subagent completion announcements dropped when parent session is idle (reopened, upstream restructured) #79053

Description

@yozakura-ava

Summary

Subagent completion announcements are silently dropped when the parent session has an active but non-consuming embedded Pi run (between turns, idle). The user only sees the result after sending another message that re-triggers the session.

This is a reopen of #75663. The original fix attempt (#75669) was closed because upstream has restructured the subagent completion delivery infrastructure — the agent-mediated completion path was removed and replaced with a sendMessage-based fallback system.

Root Cause (Current Upstream)

In sendSubagentAnnounceDirectly (src/agents/subagent-announce-delivery.ts), when requesterActivity.isActive is true but the embedded Pi run is not consuming messages:

  1. queueEmbeddedPiMessage returns false (run not streaming)
  2. The code enters the if (requesterActivity.isActive) block
  3. The function returns { delivered: false } as a dead-end — preventing fallthrough to the callGateway("agent", { expectFinal: true }) path that would start a new run and deliver the message

Proposed Fix

Replace the early-return dead-end with a sendMessage-based fallback attempt, then fall through to the gateway call if the fallback fails. This requires:

  1. Adding sendMessage to imports from subagent-announce-delivery.runtime.js
  2. Adding sendMessage to SubagentAnnounceDeliveryDeps type and defaults
  3. Adding extractThreadCompletionFallbackText, sendCompletionFallback, resolveCompletionFallbackPath helper functions
  4. Replacing the early return at if (requesterActivity.isActive) with fallback-then-fallthrough logic
  5. Updating tests to mock sendMessage via deps

Environment

  • Channel: Telegram (push-based, most affected)
  • Less affected: WebChat (polling picks up queued messages)
  • Upstream version: v2026.5.7-beta.1

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions