Skip to content

[Bug] Cron announce to Discord fails with discordVoice outbound adapter is unavailable when messages.tts.auto="always" #84952

Closed

Description

@chouzz

Summary

On OpenClaw 2026.5.19, isolated cron jobs with delivery.mode="announce" to Discord fail at delivery with:

OutboundDeliveryError: discordVoice outbound adapter is unavailable.

The agent run itself succeeds and produces a normal text summary, but outbound delivery is marked failed.

Environment

  • OpenClaw: 2026.5.19 (a185ca2)
  • Channel: Discord
  • Cron job: isolated, announce delivery to Discord channel
  • Config: messages.tts.auto = "always"

Repro Steps

  1. Configure Discord channel/account and a cron job with delivery.mode="announce" to a Discord text channel.
  2. Set messages.tts.auto to "always".
  3. Run the cron job manually with openclaw cron run <job-id>.
  4. Inspect run history with openclaw cron runs --id <job-id> --expect-final.

Observed

  • Cron execution produces valid summary text.
  • Final run status contains:
    • error: OutboundDeliveryError: discordVoice outbound adapter is unavailable.
    • delivery.resolved.ok: true (discord target resolved)
    • delivery.delivered: false
    • delivery.fallbackUsed: true

Expected

For text-only cron announce delivery targets, outbound should use normal Discord text path and succeed (or gracefully bypass voice route), even when messages.tts.auto="always".

Additional Notes

  • Setting messages.tts.auto to non-always mode (e.g. tagged) avoided the failure in local testing.
  • This looks like a regression in Discord + cron + auto-TTS delivery routing.

Example run ids

  • manual:b6d6d387-11c9-4dbe-b220-83f35d28a987:1779365221918:1
  • manual:b6d6d387-11c9-4dbe-b220-83f35d28a987:1779368021934:1

Activity

  1. clawsweeper commented on May 21, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

    Workflow note: Future ClawSweeper reviews update this same comment in place.

    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Summary
    Keep open: the report maps to a current source-level Discord cron delivery bug, not a stale or duplicate cleanup candidate. Current main still lets cron announce TTS produce an audioAsVoice Discord payload, and the CLI outbound dependency proxy can resolve discordVoice as a nonexistent channel adapter with the exact reported unavailable-adapter error.

    Reproducibility: yes. at source level: current main has a path from cron announce auto-TTS to Discord audioAsVoice, then to resolveOutboundSendDep(deps, "discordVoice"), where the CLI proxy can create the exact unavailable-adapter sender. I did not run a live Discord cron job in this read-only sweep.

    Next step
    This is a narrow source-reproducible bug with clear likely files and regression-test seams, suitable for a focused repair PR.

    Review details

    Best possible solution:

    Preserve Discord auto-TTS voice-note behavior, but prevent the CLI/cron outbound dependency layer from treating discordVoice as a normal channel id and add a regression test for Discord cron TTS delivery.

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

    Yes at source level: current main has a path from cron announce auto-TTS to Discord audioAsVoice, then to resolveOutboundSendDep(deps, "discordVoice"), where the CLI proxy can create the exact unavailable-adapter sender. I did not run a live Discord cron job in this read-only sweep.

    Is this the best way to solve the issue?

    Yes, but the narrow fix is dependency resolution, not disabling Discord TTS for cron. The maintainable solution is to keep the plugin-owned Discord voice sender available while ensuring pseudo-dependency keys such as discordVoice are not manufactured as channel adapters.

    Label changes:

    • add P2: This is a concrete current-release Discord cron delivery bug with a narrow configuration trigger and a plausible focused fix.
    • add impact:message-loss: The reported final cron announce is marked undelivered after the outbound platform-send path fails.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

    Label justifications:

    • P2: This is a concrete current-release Discord cron delivery bug with a narrow configuration trigger and a plausible focused fix.
    • impact:message-loss: The reported final cron announce is marked undelivered after the outbound platform-send path fails.

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/cli/outbound-send-mapping.test.ts
    • node scripts/run-vitest.mjs extensions/discord/src/outbound-adapter.test.ts
    • node scripts/run-vitest.mjs src/cron/isolated-agent/delivery-dispatch.double-announce.test.ts

    What I checked:

    • Cron announce applies TTS before direct delivery: dispatchCronDelivery calls maybeApplyTtsToCronPayloads for resolved announce targets, then passes the resulting payloads into sendDurableMessageBatch; this is the cron path described by the report. (src/cron/isolated-agent/delivery-dispatch.ts:320, 6ccca4ae9529)
    • Auto TTS can convert final text into an audio voice payload: maybeApplyTtsToPayload honors autoMode values other than off and, on successful synthesis, returns a payload with mediaUrl, audioAsVoice, spokenText, and trustedLocalMedia. (extensions/speech-core/src/tts.ts:1691, 6ccca4ae9529)
    • Discord advertises voice-note TTS capability: The Discord plugin declares capabilities.tts.voice.synthesisTarget = "voice-note", and speech-core treats voice-note targets as audioAsVoice when the provider result is voice-compatible. (extensions/discord/src/shared.ts:131, 6ccca4ae9529)
    • Discord audioAsVoice payloads use the voice sender: sendDiscordOutboundPayload routes payload.audioAsVoice plus media through sendContext.sendVoice, which is the point where a bad discordVoice dependency breaks delivery before normal text fallback can succeed. (extensions/discord/src/outbound-payload.ts:32, 6ccca4ae9529)
    • The Discord voice sender lookup prefers a discordVoice dependency: createDiscordPayloadSendContext resolves discordVoice from outbound deps before falling back to runtime.sendVoiceMessageDiscord; a proxy-created placeholder therefore blocks the real plugin-owned helper. (extensions/discord/src/outbound-send-context.ts:81, 6ccca4ae9529)
    • CLI dependency proxy can manufacture the exact unavailable adapter: The default CLI deps factory creates a lazy sender for arbitrary property names with unavailableMessage: "${channelId} outbound adapter is unavailable."; discordVoice is not excluded as a pseudo-dependency key. (src/cli/deps.ts:73, 6ccca4ae9529)

    Likely related people:

    • @steipete: Authored the speech voice-note routing refactor and the release commit that added the current CLI outbound dependency files implicated in the proxy behavior. (role: recent area contributor; confidence: medium; commits: f621fb4abaf3, a185ca283a74; files: extensions/speech-core/src/tts.ts, src/cli/deps.ts, src/cli/outbound-send-mapping.ts)
    • liuhuaize: Authored the commit that made Discord auto-TTS route as voice notes, which is the intended behavior now interacting with cron delivery. (role: introduced adjacent behavior; confidence: medium; commits: b3d7fd166ad5; files: extensions/speech-core/src/tts.ts, extensions/speech-core/src/tts.test.ts)
    • @tyler6204: Carried the major cron announce delivery consolidation that shaped the current dispatch path and tests. (role: cron delivery contributor; confidence: medium; commits: 38543d819690; files: src/cron/isolated-agent/delivery-dispatch.ts, src/cron/isolated-agent/delivery-dispatch.double-announce.test.ts, docs/automation/cron-jobs.md)
    • Dennis Goldfinger: Introduced direct-send behavior for text-only announce delivery, which is directly adjacent to the reported cron announce failure mode. (role: cron text announce contributor; confidence: medium; commits: 30968372384b; files: src/cron/isolated-agent/delivery-dispatch.ts, src/cron/isolated-agent.direct-delivery-forum-topics.test.ts)

    Remaining risk / open question:

    • No live Discord cron run was executed in this read-only review, so the repair PR should include either a focused regression test plus real Discord proof or a clearly documented proof gap.
    • A fix should not globally disable Discord auto-TTS voice-note delivery, because current speech-core tests intentionally route Discord auto TTS as native voice messages.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 6ccca4ae9529.

  2. added
    P2Normal backlog priority with limited blast radius.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    on May 21, 2026
  3. added a commit that references this issue on May 21, 2026
    1e4680b
  4. JulyanXu commented on May 22, 2026

    @JulyanXu
    Contributor

    Source-verified analysis:

    Traced the delivery routing chain:

    1. Error source: src/cli/deps.ts:82 — createLazySender generates the "outbound adapter is unavailable" message per channelId. When channelId = "discordVoice", it creates a lazy sender that attempts to load the voice outbound runtime, which fails because the Discord voice adapter is not available in the cron delivery context.

    2. Why discordVoice is selected: In extensions/discord/src/outbound-adapter.ts:233, when audioAsVoice === true AND there's a mediaUrl, the outbound adapter routes through discordVoice:

    const sendVoice =
      resolveOutboundSendDep<DiscordVoiceSendFn>(deps, "discordVoice") ??
      (await loadDiscordSendRuntime()).sendVoiceMessageDiscord;
    1. Why audioAsVoice is true: The messages.tts.auto = "always" config causes the TTS pipeline to generate audio and set audioAsVoice = true on the reply payload. In extensions/discord/src/monitor/reply-safety.ts:31, hasNonTextReplyPayloadContent checks payload.audioAsVoice === true to preserve voice payloads from filtering.

    2. The routing bug: Cron announce delivery for a Discord text channel should NOT route through discordVoice even when TTS generates audio. The voice adapter requires a Discord voice channel connection (which cron delivery doesn't have), while the text channel should receive the text summary + TTS audio as a regular media attachment via the discord (text) adapter.

    Fix approach:

    The outbound adapter's audioAsVoice routing logic should consider the delivery context. When the target is a text channel (not a voice channel), audioAsVoice should be downgraded to a regular media attachment delivery:

    In outbound-adapter.ts, before the audioAsVoice branch:

    if (audioAsVoice && mediaUrl) {
      // If target is not a Discord voice channel, send audio as attachment instead
      if (!isDiscordVoiceTarget(target)) {
        // Fall through to text + media delivery path
        audioAsVoice = false;
      } else {
        // ... existing voice path
      }
    }

    This ensures cron announce deliveries to text channels succeed with TTS audio as an attachment, while preserving the voice-channel delivery path for interactive sessions.

  5. JulyanXu commented on May 22, 2026

    @JulyanXu
    Contributor

    Debugged to exact lines. Precise fix:

    Root Cause

    extensions/discord/src/outbound-adapter.ts:231-245 — The sendMedia function routes to discordVoice whenever audioAsVoice && mediaUrl is true, with no check on whether the target is a Discord voice channel vs text channel:

    // outbound-adapter.ts:231-245
    if (audioAsVoice && mediaUrl) {
      const sendVoice =
        resolveOutboundSendDep<DiscordVoiceSendFn>(deps, "discordVoice") ??
        (await loadDiscordSendRuntime()).sendVoiceMessageDiscord;
      return await withDiscordDeliveryRetry({
        cfg,
        accountId,
        fn: async () =>
          await sendVoice(target, mediaUrl, { cfg, replyTo: replyToId ?? undefined, ... }),
      });
    }

    When messages.tts.auto = "always", the TTS pipeline sets audioAsVoice = true and generates a mediaUrl with the audio file. For cron announce delivery to a Discord text channel, this routes through discordVoice — but:

    1. resolveOutboundSendDep(deps, "discordVoice") returns undefined (no voice adapter in cron delivery deps)
    2. The fallback runtime.sendVoiceMessageDiscord requires an active Discord voice connection, which cron doesn't have
    3. Result: OutboundDeliveryError: discordVoice outbound adapter is unavailable

    The missing check

    The sendMedia function has no way to distinguish between delivery to a Discord voice channel (where sendVoice is correct) vs delivery to a Discord text channel (where audio should be sent as a regular file attachment).

    The target string (from resolveDiscordOutboundTarget) encodes the destination but doesn't carry voice-vs-text channel metadata.

    Exact Fix

    Add a guard that catches the unavailable voice adapter and falls through to text+media delivery:

    if (audioAsVoice && mediaUrl) {
      const sendVoice =
        resolveOutboundSendDep<DiscordVoiceSendFn>(deps, "discordVoice");
      if (sendVoice) {
        return await withDiscordDeliveryRetry({
          cfg,
          accountId,
          fn: async () =>
            await sendVoice(target, mediaUrl, {
              cfg,
              replyTo: replyToId ?? undefined,
              accountId: accountId ?? undefined,
              silent: silent ?? undefined,
            }),
        });
      }
      // Voice adapter unavailable (e.g., cron delivery to text channel).
      // Fall through to send audio as a regular media attachment.
    }

    Key change: Remove the ?? (await loadDiscordSendRuntime()).sendVoiceMessageDiscord fallback. If discordVoice isn't in deps, the voice adapter isn't available for this delivery context. Instead of trying and failing, fall through to the existing text+media delivery path (lines 246+), which sends the audio as a file attachment via the regular discord text adapter.

    The fallback to runtime.sendVoiceMessageDiscord was the bug — it attempted voice-channel delivery in a context where no voice channel exists. The correct fallback for unavailable voice is to degrade gracefully to text-channel delivery with the audio as an attachment.

    Why this works

    • When the voice adapter IS available (interactive sessions with voice channels), resolveOutboundSendDep(deps, "discordVoice") returns the function → voice delivery works as before
    • When the voice adapter is NOT available (cron delivery, text-only channels), the code falls through to the text+media path at line 246+, which correctly sends audio as a media attachment to the text channel
    • The text+media path already handles audio URLs correctly — it just wasn't being reached because the audioAsVoice branch intercepted and failed
  6. locked as resolved and limited conversation to collaborators on May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions