Skip to content

Subagent completion announcements can be premature or duplicated after tool-use turns #80498

Description

@saphoroth

Summary

KIZ-762 found two related subagent completion-announcement regressions in the OpenClaw runtime:

  1. Assistant text attached to a tool-use turn can be treated as terminal subagent completion output even though it is only progress while the child is still running.
  2. The same terminal child result can be delivered more than once for the same childSessionKey + childRunId.

This produced premature/duplicate subagent completion announcements during live orchestration work.

Proposed fix

Prepared and locally validated source patch touches:

  • src/agents/subagent-announce-output.ts
  • src/agents/subagent-announce-output.test.ts
  • src/agents/subagent-announce.ts
  • src/agents/subagent-announce.test.ts

Behavioral changes:

  • If an assistant message has tool calls, treat any attached assistant text as progress, not terminal output.
  • After non-sessions_yield tool use, wait for a later assistant message without tool calls before selecting final output.
  • Do not promote tool-result text to terminal completion while waiting for that final assistant response.
  • Add bounded in-memory terminal announce idempotency keyed by the existing stable announce id (childSessionKey + childRunId, via current announce-id machinery).

Local validation

Validated in a fresh public source checkout:

PATH="/tmp/kiz775-bin:$PATH" OPENCLAW_TEST_FAST=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.agents.config.ts src/agents/subagent-announce-output.test.ts src/agents/subagent-announce.test.ts

2 test files passed, 17 tests passed

Also ran git diff --check clean on the prepared source patch.

Notes

I attempted to push a PR branch from a fork, but the available GitHub token lacks workflow scope and GitHub rejected branch creation because the upstream/fork history includes workflow files. I am filing this issue as the upstream tracking artifact instead of silently leaving the fix local.

The prepared local branch/commit is:

/tmp/openclaw-source-kiz775
branch: kiz-762-subagent-announcement-fix
commit: 2ae383dd fix: avoid premature subagent completion announcements

I can provide the full patch if preferred.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions