Skip to content

fix: preserve media completion message-tool delivery#82206

Merged
steipete merged 2 commits into
mainfrom
fix/media-completion-message-tool
May 15, 2026
Merged

fix: preserve media completion message-tool delivery#82206
steipete merged 2 commits into
mainfrom
fix/media-completion-message-tool

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Force generated music/video completion handoffs that target group/channel chats into message_tool_only reply mode.
  • Carry sourceReplyDeliveryMode through gateway agent RPC, agentCommand, and embedded active-run queue state so the completion agent has the message tool when it must attach media.
  • Add regression coverage for generated-media group completions, active-run delivery-mode mismatch fallback, embedded queue mode checks, and gateway forwarding.

Bug

A background music task could complete successfully and still never post the mp3 back to Discord. The live #clawtributors repro was message 1504845517404770374 at 2026-05-15T13:58:50Z: the agent queued task af2bccc3-8366-47da-8f8a-0965b5cc8da8, generation finished at 14:00:27Z, but the gateway logged Media generation completion wake failed and task delivery stayed unnotified.

An earlier run showed the other half of the bug: the completion did reach the channel session, but that turn only exposed image_generate and music_generate; the group prompt also told the agent not to use message. The agent therefore produced a text-only reply and never attached the generated mp3.

Fix

Generated media completions already know when group/channel delivery must go through the message tool. This patch preserves that fact across both completion paths:

  • requester wake gets sourceReplyDeliveryMode: "message_tool_only"
  • active embedded runs record their source-reply mode and reject a forced message-tool wake if they were created without that mode
  • rejected forced wakes fall back to a fresh requester-agent handoff that carries the same mode
  • gateway agent accepts and forwards the mode into agentCommand
  • existing embedded tool construction then forces the message tool and message-tool-only prompt guidance

Verification

  • OPENCLAW_TEST_FAST=1 node scripts/run-vitest.mjs src/agents/pi-embedded-runner/runs.test.ts src/agents/subagent-announce-delivery.test.ts -t "message-tool|generated media group completions|steering options" --reporter dot
  • OPENCLAW_TEST_FAST=1 node scripts/run-vitest.mjs src/gateway/server.agent.gateway-server-agent-a.test.ts -t "sourceReplyDeliveryMode" --reporter dot
  • node_modules/.bin/oxfmt --check src/agents/command/types.ts src/agents/pi-embedded-runner/run-state.ts src/agents/pi-embedded-runner/runs.ts src/agents/pi-embedded-runner/run/attempt.ts src/agents/subagent-announce-delivery.ts src/agents/pi-embedded-runner/runs.test.ts src/agents/subagent-announce-delivery.test.ts src/gateway/protocol/schema/agent.ts src/gateway/server-methods/agent.ts src/agents/command/attempt-execution.ts src/gateway/server.agent.gateway-server-agent-a.test.ts
  • git diff --check
  • /Users/steipete/Projects/agent-scripts/skills/codex-review/scripts/codex-review

Real behavior proof

Behavior addressed: Discord group/channel generated music completions no longer lose the must-use-message-tool invariant when the completion is queued or falls back to a requester-agent run.

Real environment tested: Live #clawtributors logs/session/task DB were inspected for failed music task af2bccc3-8366-47da-8f8a-0965b5cc8da8; patch behavior was verified with focused local regression tests.

Exact steps or command run after this patch: focused Vitest shards for generated-media completion delivery, embedded queue delivery-mode handling, and gateway sourceReplyDeliveryMode forwarding; formatting and diff whitespace checks; Codex review clean.

Evidence after fix: tests assert generated-media group handoffs include sourceReplyDeliveryMode: "message_tool_only", active embedded runs reject incompatible forced wakes instead of reporting success, fallback handoff carries the forced mode, and gateway forwards that field to agentCommand.

Observed result after fix: the handoff mode reaches the embedded runner path that already forces the message tool and suppresses automatic source replies for message_tool_only turns.

What was not tested: did not re-trigger a live Discord music generation after patch before PR; the earlier broad music helper legacy WhatsApp wrapper shard was not completed because it hung under the test wrapper.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels May 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c447c113f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

acpTurnSource: request.acpTurnSource,
internalEvents: request.internalEvents,
inputProvenance,
sourceReplyDeliveryMode: request.sourceReplyDeliveryMode,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restrict sourceReplyDeliveryMode to trusted agent callers

Forwarding request.sourceReplyDeliveryMode directly into agentCommand lets any gateway agent RPC caller set "message_tool_only", which changes embedded-run tool policy and force-enables the message tool path (via embedded tool selection), expanding capabilities beyond the default caller contract. Before this schema/API change, external callers could not set this field because unknown params were rejected; now the value should be ignored or rejected for untrusted clients (similar to other internal-only agent params) to avoid privilege/capability escalation from user-controlled requests.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix: preserve media completion message-tool delivery This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete steipete added the proof: override Maintainer override for the external PR real behavior proof gate. label May 15, 2026
@steipete steipete merged commit c6ddb1a into main May 15, 2026
86 of 91 checks passed
@steipete steipete deleted the fix/media-completion-message-tool branch May 15, 2026 15:49
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix: preserve message-tool media completion delivery

* chore: update generated protocol models
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix: preserve message-tool media completion delivery

* chore: update generated protocol models
SYU8384 pushed a commit to SYU8384/openclaw that referenced this pull request Jun 3, 2026
* fix: preserve message-tool media completion delivery

* chore: update generated protocol models
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* fix: preserve message-tool media completion delivery

* chore: update generated protocol models
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR proof: override Maintainer override for the external PR real behavior proof gate. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant