openclaw - ✅(Solved) Fix [Bug] Auto-compaction race: readSubagentOutput returns stale tool JSON instead of post-compaction assistant reply [2 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#74073Fetched 2026-04-30 06:29:03
View on GitHub
Comments
2
Participants
3
Timeline
10
Reactions
0
Author
Timeline (top)
cross-referenced ×6commented ×2mentioned ×1subscribed ×1

Fix Action

Fix / Workaround

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.

PR fix notes

PR #74113: fix(subagent-announce): unified post-compaction retry before finalizing output

Description (problem / solution / changelog)

Fix #74073\n\nWhen a sub-agent uses tools that trigger auto-compaction mid-turn (e.g. Grok/DeepSeek + web_search returning a large Tavily JSON), the announce flow resolves before the post-compaction assistant message is produced. returns stale tool JSON, which then leaks into the parent session as the announcement.\n\nThis PR adds a unified retry after both the and fallback branches resolve:\n1. After both branches complete, call once\n2. If the assistant has produced newer output (different from captured reply) and it's not a silent/announce-skip token, use it instead\n\nThis mirrors the approach described in the issue's suggested fix without modifying the core retry loop structure.

Changed files

  • src/agents/subagent-announce.ts (modified, +23/-0)

PR #74340: fix(subagents): avoid raw tool output as completion result

Description (problem / solution / changelog)

Summary

  • stop treating raw tool results as the completion payload for successful subagent runs
  • keep timeout partial-progress behavior intact
  • add regression coverage for successful tool-only histories

Why

A subagent can finish after only tool calls (or lose its final assistant reply). The announce path previously fell back to the latest raw tool result, which can leak huge grep/build output as the child result and make a tool-only run look like a successful user-facing report.

Test

  • pnpm exec vitest run src/agents/subagent-announce-output.test.ts src/agents/subagent-announce.timeout.test.ts --pool forks --maxWorkers=1

Changed files

  • src/agents/subagent-announce-output.test.ts (modified, +22/-0)
  • src/agents/subagent-announce-output.ts (modified, +6/-0)
RAW_BUFFERClick to expand / collapse

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)

extent analysis

TL;DR

Implement a unified retry mechanism after both branches complete to ensure post-compaction output is available before evaluating the outcome.

Guidance

  • Identify the subagent-announce-Dim2fAZI.js file and locate the runSubagentAnnounceFlow and childCompletionFindings functions to apply the suggested fix.
  • Add a unified retry loop that checks for readLatestAssistantReply and polls for delayed post-compaction output if necessary.
  • Verify the fix by testing with Grok / DeepSeek + web_search and checking that the raw tool-result text is not injected into the parent session as the announcement.
  • Consider reviewing related issues #67750 and #70334 for additional context on compaction edge cases.

Example

// Pseudo-code example of the unified retry loop
if (childCompletionFindings || !childCompletionFindings) {
  // Unified retry loop
  const retryCount = 0;
  const maxRetries = 12; // approximately 35s with 3s polling
  while (retryCount < maxRetries) {
    const latestReply = readLatestAssistantReply({ sessionKey, limit: 100 });
    if (latestReply && isAnnounceSkip(latestReply) || isSilentReplyText(latestReply)) {
      // Handle announce skip or silent reply text
      break;
    } else if (latestReply) {
      // Post-compaction output is available, proceed with evaluation
      break;
    }
    // Poll every 3s for delayed post-compaction output
    await new Promise(resolve => setTimeout(resolve, 3000));
    retryCount++;
  }
}

Notes

The suggested fix assumes that the readLatestAssistantReply function and isAnnounceSkip/isSilentReplyText checks are correctly implemented and functional.

Recommendation

Apply the workaround by implementing the unified retry mechanism

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug] Auto-compaction race: readSubagentOutput returns stale tool JSON instead of post-compaction assistant reply [2 pull requests, 2 comments, 3 participants]