Skip to content

ACP sessions never trigger auto-announce (missing lifecycle event in dispatch-acp path) #40693

Description

@EscalioDev

Bug Description

ACP sessions spawned via sessions_spawn({ runtime: "acp", mode: "run" }) never trigger the auto-announce flow to the parent session.

Root Cause (traced in source)

The announce system depends on lifecycle events with phase: "end":

  1. Standard subagent runs go through runEmbeddedPiAgent → emits { stream: "lifecycle", phase: "end" } when done
  2. The subagent registry listener (ensureListener in reply-*.js) picks up that event → calls completeSubagentRun → triggers runSubagentAnnounceFlow → announces to parent

ACP sessions take a different code path:

  • ACP turns dispatch via tryDispatchAcpReplyacpManager.runTurn()
  • When the ACP turn completes, it calls recordProcessed("completed") and markIdle("message_completed")
  • It never emits the lifecycle event with phase: "end"
  • So the subagent registry listener never fires → no announce

Expected Behavior

ACP sessions spawned with mode: "run" should auto-announce their completion to the parent session, just like standard subagent runs.

Reproduction

sessions_spawn({
  task: "echo hello",
  runtime: "acp",
  agentId: "claude",
  mode: "run",
  thread: true
})

The session completes but no announce message appears in the parent session or Discord channel.

Environment

  • OpenClaw: v2026.3.7
  • acpx: v0.1.15
  • Node: 22.19.0
  • OS: macOS (arm64)

Suggested Fix

In tryDispatchAcpReply (src/auto-reply/reply/dispatch-acp.ts), after acpManager.runTurn() completes successfully, emit:

emitAgentEvent({
  runId,
  stream: "lifecycle",
  data: {
    phase: "end",
    endedAt: Date.now()
  }
});

This would connect the ACP completion to the existing announce pipeline.

Workaround

Parent agent manually announces via message(action=send) after detecting ACP completion through streamTo: "parent" system events.

Metadata

Metadata

Assignees

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