fix: preserve media completion message-tool delivery#82206
Conversation
There was a problem hiding this comment.
💡 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, |
There was a problem hiding this comment.
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 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. |
* fix: preserve message-tool media completion delivery * chore: update generated protocol models
* fix: preserve message-tool media completion delivery * chore: update generated protocol models
* fix: preserve message-tool media completion delivery * chore: update generated protocol models
* fix: preserve message-tool media completion delivery * chore: update generated protocol models
Summary
message_tool_onlyreply mode.sourceReplyDeliveryModethrough gatewayagentRPC,agentCommand, and embedded active-run queue state so the completion agent has themessagetool when it must attach media.Bug
A background music task could complete successfully and still never post the mp3 back to Discord. The live
#clawtributorsrepro was message1504845517404770374at2026-05-15T13:58:50Z: the agent queued taskaf2bccc3-8366-47da-8f8a-0965b5cc8da8, generation finished at14:00:27Z, but the gateway loggedMedia generation completion wake failedand 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_generateandmusic_generate; the group prompt also told the agent not to usemessage. 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:
sourceReplyDeliveryMode: "message_tool_only"agentaccepts and forwards the mode intoagentCommandmessagetool and message-tool-only prompt guidanceVerification
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 dotOPENCLAW_TEST_FAST=1 node scripts/run-vitest.mjs src/gateway/server.agent.gateway-server-agent-a.test.ts -t "sourceReplyDeliveryMode" --reporter dotnode_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.tsgit diff --check/Users/steipete/Projects/agent-scripts/skills/codex-review/scripts/codex-reviewReal 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
#clawtributorslogs/session/task DB were inspected for failed music taskaf2bccc3-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
sourceReplyDeliveryModeforwarding; 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 toagentCommand.Observed result after fix: the handoff mode reaches the embedded runner path that already forces the
messagetool and suppresses automatic source replies formessage_tool_onlyturns.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.