Repository navigation
Description
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 idRoot 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:43takeschannel+chat_id+thread_idas plain arguments. It holds no reference to an execution, a turn, or a session;execution_idis used only for theeffect_guarddedup key._deliver_telegram(voice_reply_service.py:130) authenticates withdb.get_telegram_bot_token(agent_name)— the agent's long-lived bot token — and callsTelegramAdapter._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 + TwilioMediaUrl) 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:475resolvesrecipient_email → chat_idviadb.get_telegram_chat_link_by_verified_email(binding["id"], recipient_email)— behinddb.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_stamptakes a schedule'sagent_schedules.deliver_to_workspace_email, resolves the destination and writes it onto the execution row withdb.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
- The refusal names the input, not the constraint.
not_a_channel_turntells 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". - 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 inallowed_toolswith no accompanying prompt fragment — and the schedule API/UI acceptsmcp__trinity__send_voice_replyinallowed_toolswithout objection. The tool is offered where it structurally cannot work. - It is undocumented. Neither
docs/memory/architecture/mcp-server.mdnorapi-endpoints.mdstates 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) returnsNoneon over-length, which surfaces asreason: "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_messageenforcescan_agent_message_emailconsent + 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
- 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.
- Whichever route lands, the proactive send passes the same consent + rate-limit gates as
send_message. - If any trigger class remains unable to deliver, its
reasonnames the constraint and carries aguidancesentence, 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 barenot_a_channel_turn. - The schedule configuration surface does not silently accept a tool that cannot work on that trigger (warn, or make it work).
TTS_MAX_CHARSrejection returns its own reason, distinct fromsynthesis_failed.docs/memory/architecture/mcp-server.md+api-endpoints.mdstate 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
vybe commentedon Sep 24, 2026
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.feat(voice): proactive voice notes — address send_voice_reply by role…