Skip to content

bug(voice): send_voice_reply cannot deliver from a scheduled execution — the destination is read only from an inbound channel stamp, and the refusal names the trigger instead of the constraint #2999

Open

Description

@vybe

Summary

send_voice_reply refuses with not_a_channel_turn when called from a scheduled (cron) execution, while send_message addressed to the same person on the same channel, from the same execution, delivers normally. The refusal is not a channel, provider or cost constraint — the delivery layer is already fully proactive-capable. The whole coupling is one line of destination resolution: the voice route reads the destination off the execution row, and only an inbound channel turn ever stamps that row.

Reproduction

In an execution with triggered_by = "schedule" (voice enabled for the agent, the Telegram channel flag on, the tool present in the schedule's allowed_tools):

// mcp__trinity__send_voice_reply(text: "...", execution_id: "<this run's own id>")
{ "delivered": false, "channel": "schedule", "reason": "not_a_channel_turn", "fallback_to_text": true }

// mcp__trinity__send_message(recipient_email: "<a verified, linked recipient>", channel: "telegram", ...)
// → delivered, with a Telegram message id

Root cause (read from the source, dev @ 96795e2)

1. The refusal is raised on the execution row's trigger, not on any capability:

src/backend/routers/agents.py:1442-1490 — send_voice_reply_endpoint:

channel = execution.source_channel or execution.triggered_by
...
if channel not in ("telegram", "slack", "whatsapp"):
    return {"delivered": False, "channel": channel, "reason": "not_a_channel_turn"}
if not execution.source_channel_chat_id:
    return {"delivered": False, "channel": channel, "reason": "no_destination"}

A cron fire has source_channel = NULL and triggered_by = "schedule", so channel resolves to the literal string "schedule", fails the membership test, and returns before any voice logic runs.

2. source_channel* is only ever stamped by an inbound turn. Per §48.1 FR-3 the three columns exist so the tool can "reconstruct the exact delivery target", and adapters/message_router.py:731-737 is the only writer on the messaging-channel path. There is no channel-stamping path for a scheduled run, so the row can never carry one.

3. The send path below the router is already stateless and proactive-capable — this is the part that makes it a missing route rather than a limitation:

  • services/voice_reply_service.py:43 takes channel + chat_id + thread_id as plain arguments. It holds no reference to an execution, a turn, or a session; execution_id is used only for the effect_guard dedup key.
  • _deliver_telegram (voice_reply_service.py:130) authenticates with db.get_telegram_bot_token(agent_name) — the agent's long-lived bot token — and calls TelegramAdapter._send_voice → sendVoice (adapters/telegram_adapter.py:953). No session token, no 24h window, no inbound-message precondition. Slack (slack_service.upload_file) and WhatsApp (hosted media + Twilio MediaUrl) are the same shape.

4. The addressing that is missing here already exists elsewhere in the codebase, in two places:

  • services/proactive_message_service.py:475 resolves recipient_email → chat_id via db.get_telegram_chat_link_by_verified_email(binding["id"], recipient_email) — behind db.can_agent_message_email() consent and a per-recipient rate limit. That is exactly the lookup the voice route lacks.
  • ent#498 already solved this problem class for scheduled runs on the Workspace surface: services/schedule_workspace_delivery.py::resolve_and_stamp takes a schedule's agent_schedules.deliver_to_workspace_email, resolves the destination and writes it onto the execution row with db.stamp_execution_channel_context(...) before the run starts. A cron run can carry a stamped destination today — just never a messaging-channel one.

Verdict: not a deliberate guard. §48.1 (requirements/public-access.md) scopes the feature to "during a channel turn" / "user-facing channel triggers only", but records no rationale — no cost, session-token or provider constraint is cited, and none exists in the code. not_a_channel_turn is a catch-all for "this row has no channel destination" (the same string is reused for room rows in tests/unit/test_2792_room_work_chat_id.py), not a statement about the scheduled path.

Why this is a bug and not only a missing feature

  1. The refusal names the input, not the constraint. not_a_channel_turn tells an agent what its execution is, never what voice actually needs. This is precisely the class bug(voice): agents tell Workspace clients the surface is text-only — portal TTS is never advertised, and the channel/portal voice gates disagree #2157 fixed for the Workspace — a bare code that agents over-generalize into a false claim. A caller reading this one cannot tell "not implemented for cron" from "this surface has no audio".
  2. Nothing signals it at configuration time. FR-5's capability advertisement (platform_prompt_service.py:1061) is composed only on the channel path, so a scheduled run gets the tool in allowed_tools with no accompanying prompt fragment — and the schedule API/UI accepts mcp__trinity__send_voice_reply in allowed_tools without objection. The tool is offered where it structurally cannot work.
  3. It is undocumented. Neither docs/memory/architecture/mcp-server.md nor api-endpoints.md states that a non-channel trigger can never deliver, so a scheduled voice deliverable is a reasonable thing to design and then discover at runtime.

Two adjacent findings from the same read

  • The cost cap is indistinguishable from a provider failure. tts_service._within_cost_cap (TTS_MAX_CHARS, default 1500) returns None on over-length, which surfaces as reason: "synthesis_failed" — the same code as a credential or provider error. A caller that could shorten its text cannot tell that shortening is the fix. A distinct reason (e.g. text_too_long, with the cap) would make it actionable.
  • Any proactive voice route must inherit the text path's gates. send_message enforces can_agent_message_email consent + a per-recipient hourly rate limit; the voice route has neither, because an inbound turn is its own implicit consent. Adding addressing without those gates would make voice the cheaper way to bypass proactive-messaging consent.

Acceptance criteria

  1. A scheduled execution can deliver a voice note to a consenting, channel-linked recipient — via an addressing parameter on the tool, or by stamping the channel destination onto the execution row before the run (the ent#498 shape), or both.
  2. Whichever route lands, the proactive send passes the same consent + rate-limit gates as send_message.
  3. If any trigger class remains unable to deliver, its reason names the constraint and carries a guidance sentence, in the bug(voice): agents tell Workspace clients the surface is text-only — portal TTS is never advertised, and the channel/portal voice gates disagree #2157 pattern — never a bare not_a_channel_turn.
  4. The schedule configuration surface does not silently accept a tool that cannot work on that trigger (warn, or make it work).
  5. TTS_MAX_CHARS rejection returns its own reason, distinct from synthesis_failed.
  6. docs/memory/architecture/mcp-server.md + api-endpoints.md state which triggers can deliver voice.

Scope note

The capability itself — proactive voice notes addressed to a recipient from a non-channel run — is tracked as a feature on the private tracker; this issue is the defect surface: the opaque refusal, the unsignalled configuration, the undocumented limit, and the cap/consent seams above.

Activity

  1. added
    priority-p2
    type-bug
    theme-channels
    complexity-medium
    on Sep 24, 2026
  2. vybe commented on Sep 24, 2026

    @vybe
    ContributorAuthor

    Capability half tracked privately as abilityai/trinity-enterprise#700 (proactive addressing surface, plus the consent + rate-limit gates it must inherit from the proactive text path). This issue stays the defect surface: refusal wording, configuration-time signal, docs, and the cap/consent seams.

  3. added
    status-ready
    on Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p2status-readytheme-channelstype-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions