Skip to content

Bug: sub-agent announce completion causes parent session to generate out-of-context replies #74286

@kansjwqwq

Description

@kansjwqwq

Bug Description

When a sub-agent or cron job with `delivery.mode: "announce"` completes, the parent session receives an `inter_session` injection containing only the task result, without any of the parent session's conversation context. This causes the parent session to generate replies that are completely irrelevant to what the user was actually discussing.

Steps to Reproduce

  1. Have an active main session conversation (e.g., user is debugging a cron issue)
  2. Spawn a sub-agent with `delivery.mode: "announce"` to execute a task
  3. Sub-agent completes and triggers the announce mechanism
  4. Result: The parent session generates a reply based ONLY on the task result + system instruction, with no awareness of the ongoing conversation. The reply often makes no sense in context.

Evidence

In this case, the user was debugging why a cron task failed. The main session was actively investigating. When a sub-agent completed, the parent session was injected with:

"A completed subagent task is ready for user delivery. Convert the result above into your normal assistant voice and send that user-facing update now."

But it had NO visibility into:

  • What the user was previously asking
  • The current debugging context
  • The conversation topic

So instead of acknowledging the cron investigation context, it generated: "你这cron是几分钟跑一次?感觉比我心跳还频繁 😅 要不要调低频率省点token?" — completely unrelated to what the user was actually doing.

Root Cause

File: `dist/subagent-announce-Dim2fAZI.js` (compiled, not TypeScript source)

In `buildAnnounceReplyInstruction()` (line 29-32), the injected instruction tells the parent session to "convert the result into your normal assistant voice" — but the injection message (`triggerMessage`) only contains:

  1. The task result/findings
  2. The system instruction

It does NOT include the parent session's recent conversation history.

The parent session then generates a reply with essentially zero context about what the user was doing.

Suggested Fix

When building the `triggerMessage` for the parent session, inject a summary of the parent session's recent conversation context (last N messages) so the parent session can generate contextually appropriate replies.

Specifically, modify `buildAnnounceReplyInstruction` or the `internalEvents` construction in `enqueueOrBypassSubagentAnnounce()` to include parent session conversation history in the trigger message.

Workaround

Set `delivery.mode: "none"` on cron jobs, so they only send messages via `message` tool internally without triggering the parent session announce reply mechanism.


  • OpenClaw version: 2026.4.26 (be8c246)
  • Channel: Feishu
  • Session type: Cron job with sub-agent

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    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