Skip to content

[Feature]: Sub-agent announce routing to parent session (orchestrator pattern) #12730

@ivalsaraj

Description

@ivalsaraj

Summary

When using sessions_spawn to run sub-agents, the announce result is always posted directly to the requester chat channel (e.g., Slack DM, WhatsApp). There is no way to route the announce back to the parent agent session first, so the parent can review, filter, summarize, or gate the output before it reaches the user.

This makes it difficult to build orchestrator patterns where the main agent acts as a coordinator — spawning multiple sub-agents and intelligently relaying their results.

Current flow:

Parent agent → spawns sub-agent → sub-agent finishes → announce → directly to user chat
                                                                   (parent is bypassed)

Desired flow:

Parent agent → spawns sub-agent → sub-agent finishes → announce → parent session (system event)
                                                                   → parent reviews/filters
                                                                   → parent relays to user

Proposed solution

Add an announce parameter to sessions_spawn:

sessions_spawn({
  task: "...",
  announce: "user" | "parent" | "skip"  // default: "user" (current behavior)
})
  • "user" (default): Current behavior — announce goes directly to the requester chat channel.
  • "parent": Inject the announce result as a system event into the spawning (parent) session. The parent agent can then decide what to relay.
  • "skip": Equivalent to current ANNOUNCE_SKIP behavior — nothing is posted.

When announce: "parent", the system event injected into the parent session should include:

  • Sub-agent status (success/error/timeout)
  • The announce summary text
  • childSessionKey and sessionId for sessions_history follow-up
  • Token usage and cost stats

Relevant source files

  • src/agents/tools/sessions-spawn-tool.ts — spawn tool params
  • src/agents/subagent-announce.ts — announce execution logic
  • src/agents/tools/sessions-announce-target.ts — announce target resolution (key file for this change)
  • src/agents/subagent-announce-queue.ts — announce queue
  • src/config/types.agent-defaults.ts — agent defaults schema

Documentation reference

Current behavior documented in docs/tools/subagents.md:

"The announce step runs inside the sub-agent session (not the requester session)."
"The announce reply is posted to the requester chat channel via a follow-up agent call (deliver=true)."

Alternatives considered

  1. ANNOUNCE_SKIP + manual polling: Parent spawns with task ending in "reply ANNOUNCE_SKIP", then polls sessions_history. Works but is fragile — parent has no trigger to know when to poll.

  2. Constraining announce content via task instructions: Currently used (e.g., "prefix with 🤖, be factual"). Limits noise but doesn't give the parent agent control over delivery.

  3. sessions_send from sub-agent to parent: Sub-agents don't have session tools by default (by design), so this isn't possible without relaxing tool policy.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    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