Skip to content

[Bug] Auto-compaction race: readSubagentOutput returns stale tool JSON instead of post-compaction assistant reply #74073

@dcapclaw

Description

@dcapclaw

Version: OpenClaw 2026.4.26 (reproduced from 2026.4.15 onward)

File: dist/subagent-announce-Dim2fAZI.js (hash floats; the file with runSubagentAnnounceFlow / childCompletionFindings)

Symptom

When a sub-agent uses tools that trigger auto-compaction mid-turn (most reliably reproduced with Grok / DeepSeek + web_search returning a large Tavily JSON payload), the announce flow's agent.wait resolves before the post-compaction assistant message is produced. readSubagentOutput then returns the raw tool-result text (Tavily JSON, etc.) as the "reply", which is checked against ANNOUNCE_SKIP, fails, and the raw JSON gets injected into the parent session as the announcement.

Cause

The post-compaction retry loop only ran inside the if (childCompletionFindings) { ... } branch in earlier versions. After the 4.26 split into subagent-announce-*.js, both branches still resolve before post-compaction output is available; there is no unified retry that covers both paths.

Suggested fix

After both the !childCompletionFindings and childCompletionFindings branches complete, before evaluating outcome, run a unified retry:

  1. If readLatestAssistantReply({sessionKey, limit:100}) returns text, re-check it for isAnnounceSkip / isSilentReplyText.
  2. Otherwise poll every 3s for up to ~35s for delayed post-compaction output.

Running locally as a patch — without it, every Grok+web_search sub-agent leaks its tool JSON to the parent. Happy to PR if useful.

Related: #67750, #70334 (compaction edge cases)

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