Skip to content

fix: require mediated delivery for subagent announce completions#80223

Closed
moeedahmed wants to merge 3 commits into
openclaw:mainfrom
moeedahmed:fix/subagent-announce-require-mediated-delivery
Closed

fix: require mediated delivery for subagent announce completions#80223
moeedahmed wants to merge 3 commits into
openclaw:mainfrom
moeedahmed:fix/subagent-announce-require-mediated-delivery

Conversation

@moeedahmed

@moeedahmed moeedahmed commented May 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Treat subagent_announce completions like other agent-mediated completion sources so group/channel completions do not fall back to raw child-result delivery when the completion agent fails to deliver through the message tool.

Why

Subagent completion events are internal handoff data. In visible group/channel surfaces, the requester/orchestrator should deliver a normal user-facing response. If the completion agent does not use the message tool, the runtime should report the missing mediated delivery instead of raw-sending child output.

Change

  • Add subagent_announce to the agent-mediated completion source set.
  • Add regression coverage proving channel completions with subagent_announce do not raw-send fallback output when message-tool delivery is missing.

Tests

npm test -- --run src/agents/subagent-announce-delivery.test.ts

Result: 31/31 passed.

Real behavior proof

Behavior or issue addressed: Subagent completion events could fall back to raw child-result delivery in visible group/channel surfaces if the completion agent did not deliver through the message tool.

Real environment tested: Moeed's live OpenClaw 2026.5.5 installation on macOS with the installed runtime hotfix matching this source change.

Exact steps or command run after the patch: Applied/verified the local installed-runtime hotfix with the OpenClaw reapply bundle, inspected the installed runtime marker, and verified the bundle against the live installed OpenClaw version.

Evidence after fix: Copied live terminal output from the real OpenClaw setup:

/opt/homebrew/lib/node_modules/openclaw/dist/subagent-announce-delivery-*.js:
const AGENT_MEDIATED_COMPLETION_TOOLS = new Set(["music_generate", "video_generate", "subagent_announce"]);
error: "completion agent did not deliver through the message tool"

Live patch verification command output:

Installed OpenClaw version: 2026.5.5
already patched
telegram-buttons-and-leak-hotfix: verified

Observed result after fix: subagent_announce is handled through the mediated-delivery guard in the installed runtime, so group/channel completion paths require message-tool/orchestrator delivery instead of falling back to raw child-result output.

What was not tested: I did not send another raw child result into a public Telegram group after the patch; the live verification confirms the installed runtime carries the mediated-delivery guard, and the targeted regression covers the fallback path.

Contributor response to ClawSweeper proof request

Additional live proof from the later subagent delivery validation:

After applying the equivalent installed-runtime fix locally, a native subagent smoke completion returned through the internal subagent_announce completion path for Operator mediation rather than as a raw child-result message in Telegram.

Redacted live evidence:

Native subagent smoke marker: SUBAGENT_RESTART_POLISH_OK_20260512
Observed delivery path: internal subagent_announce completion event to Operator
Observed user-facing behaviour: no raw child-result dump posted directly to the Telegram group

This is the behaviour the PR is intended to preserve: subagent_announce completions are treated as mediated agent completions, so the requester/orchestrator owns the visible user-facing report and raw child output is not used as a fallback visible message.

The installed runtime was also inspected after the hotfix and showed:

AGENT_MEDIATED_COMPLETION_TOOLS includes "subagent_announce"
Missing mediated delivery produces: "completion agent did not deliver through the message tool"

Targeted regression remains:

src/agents/subagent-announce-delivery.test.ts: 31/31 passed

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: L triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 10, 2026
@moeedahmed moeedahmed force-pushed the fix/subagent-announce-require-mediated-delivery branch from 15a9af4 to 0cdaef5 Compare May 10, 2026 10:34
@moeedahmed moeedahmed force-pushed the fix/subagent-announce-require-mediated-delivery branch from 0cdaef5 to 21738b1 Compare May 10, 2026 10:35
@clawsweeper

clawsweeper Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

Summary
The PR adds subagent_announce to the agent-mediated completion source set and adds regression coverage that Slack channel completions without message-tool delivery do not raw-send child output.

Reproducibility: yes. source-level: production subagent completions pass sourceTool: "subagent_announce", while current main excludes that source from the mediated completion set. Group/channel completion policy defaults to message_tool_only, which makes the missing guard observable on visible channel surfaces.

Real behavior proof
Sufficient (terminal): The PR body and later comment provide redacted live terminal/log evidence from an installed runtime showing the after-fix mediated path and no raw Telegram group dump.

Next step before merge
A narrow automated repair can address the blocking PR finding by adding message-tool delivery guidance or runtime mode and focused regression coverage.

Security
Cleared: The diff only changes agent completion delivery logic and test coverage; it does not alter dependencies, CI, secrets, permissions, packaging, or code-execution surfaces.

Review findings

  • [P2] Add message-tool guidance before requiring it — src/agents/subagent-announce-delivery.ts:62
Review details

Best possible solution:

Keep the mediated-delivery guard, but pair it with explicit message-tool-only guidance or an equivalent runtime mode for subagent_announce completion agents, then land with focused regression coverage.

Do we have a high-confidence way to reproduce the issue?

Yes, source-level: production subagent completions pass sourceTool: "subagent_announce", while current main excludes that source from the mediated completion set. Group/channel completion policy defaults to message_tool_only, which makes the missing guard observable on visible channel surfaces.

Is this the best way to solve the issue?

No. Adding the set entry blocks raw fallback, but without message-tool-only guidance or runtime mode it can turn a normal completion final answer into a missing-delivery failure.

Full review comments:

  • [P2] Add message-tool guidance before requiring it — src/agents/subagent-announce-delivery.ts:62
    Adding subagent_announce to the mediated set makes group/channel completions call the requester with deliver:false and require message-tool evidence. The subagent completion prompt still only asks for a normal user-facing update, so a normal final answer stays private and the delivery reports completion agent did not deliver through the message tool. Please add the same message-tool-only guidance or an equivalent runtime mode used by media completions.
    Confidence: 0.84

Overall correctness: patch is incorrect
Overall confidence: 0.86

Acceptance criteria:

  • pnpm test src/agents/subagent-announce-delivery.test.ts
  • pnpm test src/agents/subagent-announce.format.e2e.test.ts
  • pnpm check:changed

What I checked:

Likely related people:

  • steipete: History on the central subagent announce files includes repeated delivery-pipeline and structured-event work by Peter Steinberger, including the unified announce delivery pipeline and later helper refactors. (role: recent area contributor; confidence: high; commits: 4258a3307f5a, 4c43fccb3e03, b75be0914491; files: src/agents/subagent-announce-delivery.ts, src/agents/subagent-announce.ts)
  • tyler6204: History shows multiple subagent announce delivery and routing fixes by Tyler Yust, including extension-channel delivery, descendant gating, and announce-chain repairs. (role: adjacent feature contributor; confidence: medium; commits: 41cf93efff4d, 38543d819690, 81b93b9ce04b; files: src/agents/subagent-announce-delivery.ts, src/agents/subagent-announce.ts)

Remaining risk / open question:

Codex review notes: model gpt-5.5, reasoning high; reviewed against 26da4edbe150.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 10, 2026
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 10, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 11, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 11, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 11, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 11, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 11, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 11, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 11, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 11, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 11, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 11, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 11, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 11, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 12, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 14, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 14, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 14, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 14, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 14, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 14, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 14, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 14, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 14, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 14, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 14, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 15, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 15, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 15, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 15, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 15, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
@moeedahmed

Copy link
Copy Markdown
Contributor Author

Fresh real-behavior recurrence — 2026-05-15

Reproduced the exact failure this PR addresses on installed runtime
openclaw 2026.5.12 today, with two independent observations:

Observation 1 — gateway log (14:01–14:06 GMT+1):

Operator dispatched parallel ACP workers via sessions_spawn with
expectsCompletionMessage: true (the default). Workers completed
successfully (sqlite task_runs.status='succeeded'), but the
subagent_announce completion path failed to deliver:

14:06:06 Subagent completion direct announce failed for run bbbab85e-...:
          completion agent did not produce a visible reply
14:06:07 (same, retry)
14:06:10 (same, retry)

Worker output was lost. User saw nothing in Telegram. Operator manually
retried as a single sub-agent run.

Observation 2 — independent ACP-route test (14:08 GMT+1):

Operator separately tested the Claude Code ACP route on a different
governance task and reported:

The Claude Code route did launch, but it did not return the
requested patch plan. It returned only progress updates twice, and
my follow-up asking it to produce the full 8-section deliverable
timed out. ... ACP spawning works, but this Claude Code route is
currently stopping too early and treating progress as completion.
I would not trust it for canonical AGENTS.md refactoring yet.

Same root: announce-side delivery commits on intermediate output rather
than waiting for the agent's actual final, dropping the real deliverable.

24h ACP success/failure ratio on this installation:

status count
succeeded 71
failed 10
cancelled (manual) 2
running 2

Of the 71 succeeded, ~16% had terminal update delivery failed in
openclaw tasks audit — work completed but result never reached user.

PR labels show proof: supplied + proof: sufficient. All CI checks
are CANCELLED (not failed). Can a maintainer re-trigger the workflows,
or indicate what specific change is still needed? This is now recurring
frequently enough to block sub-agent usage entirely on real workloads.

Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 15, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 15, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 16, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 16, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 16, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 16, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
Jerry-Xin added a commit to Jerry-Xin/openclaw that referenced this pull request May 16, 2026
The subagent_announce addition to AGENT_MEDIATED_COMPLETION_TOOLS was
unrelated to the routing fix and could cause group/channel completions
to fail silently when the subagent does not use the message tool.

This should be addressed separately with proper message-tool-only
guidance (tracked in openclaw#80223).
@steipete

Copy link
Copy Markdown
Contributor

Closing as superseded by #82834.

This PR covers the same subagent announce delivery seam. #82834 includes the mediated-completion behavior here plus the broader completion-delivery hardening and contributor credit, so keeping #82834 as the canonical path. Thanks for the focused fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling mantis: telegram-visible-proof Mantis should capture Telegram visible proof. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants