BaseChannel.send_response docstring promises async-generator streaming that four of the five channels raise TypeError on

Open
#136 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 5 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
50/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
documentation

Research direction

The docstring to change is BaseChannel.send_response in src/tac/channels/base.py (lines 90-105), which says it supports async-generator streaming unconditionally. Compare it with the Raises: block in MessagingChannel.send_response in src/tac/channels/messaging.py (lines 208-220), and check voice/provider.py:95 for the per-provider behaviour. Done means the base docstring no longer promises generators on every channel. The issue says the exact wording is the maintainers' call, so confirm it with them before editing.

Written by the indexing model from the issue text.

Description

Summary

BaseChannel.send_response's docstring states that generator streaming is supported, with no qualification. Four of the five concrete channels raise TypeError when given one.

The docstring one file over — MessagingChannel.send_response — already states the restriction correctly, including a Raises: block. So this is an internal contradiction with the fix already drafted in your own source, rather than a request for new documentation.

All line references are at 2c24bd98, read 2026-10-09.

The abstract base asserts it unconditionally

src/tac/channels/base.py:90-105:

@abstractmethod
async def send_response(
    self,
    conversation_id: str,
    response: str | AsyncGenerator[str | dict[str, Any], None],
    role: str | None = None,
) -> None:
    """
    Send response back through the channel.

    Supports both simple string responses and streaming via async generators.
    ...

Four of five channels raise

src/tac/channels/messaging.py:218-220:

channel_name = self.get_channel_name()
if not isinstance(response, str):
    raise TypeError(f"{channel_name} channel only supports string responses")

SMSChannel, RCSChannel, WhatsAppChannel and ChatChannel all subclass MessagingChannel, and none of them overrides send_response — measured over every file under src/tac/channels/, which contains exactly two channel-level send_response definitions (the abstract one in base.py and the concrete one in messaging.py) plus voice/channel.py's delegation.

So the type and the base docstring both advertise a parameter shape that raises on four of the five channels a user can reach.

The correct wording already exists in this repo

src/tac/channels/messaging.py:208-215 — same method, overriding class:

response: Message content. Must be str — messaging channels send a single complete message via the Conversation Orchestrator Send API and do not support streaming (unlike the Voice channel).

Raises: TypeError: If response is not a string (e.g. an async generator is passed, since messaging channels don't support streaming)

That is accurate, and it is the text the base class is missing.

Suggested change

Qualify base.py:99 so the base does not promise what most implementations refuse — for example:

Supports simple string responses on every channel. Streaming via async generators is supported only where the channel's provider implements it; MessagingChannel and its subclasses raise TypeError for a generator, and voice support depends on the configured provider.

A narrower variant, if you would rather not describe subclass behaviour in the base: drop the "Supports both ..." sentence and point at the implementing class.

One related observation, offered rather than asserted as a defect

Voice support is also per-provider rather than per-channel, so "streaming is a voice capability" is not quite the invariant either. VoiceChannel.send_response (voice/channel.py:502) delegates to its provider; voice/provider.py:95 raises NotImplementedError by default, and media_streams/shared/openai_provider.py:223-233 raises for a string and a generator, with a clear reason in its docstring ("the model streams audio to Twilio directly, so there is no text response for this provider to send").

That design seems deliberate and reads well — mentioning it only because any rewording of the base docstring will want to account for it.

Why an issue and not a pull request

These are docstrings in hand-written source, so a PR would be mechanically simple. Filing as an issue because the right wording is a judgement about what the base class means to promise, which is yours rather than ours.

Context

We maintain a cross-provider specification of the TAC response-streaming contract and read connector source to verify each claim in it. This came out of promoting that document's unverified assertions to quoted-source ones, and the original claim — that a connector satisfies TAC by returning a string or an async generator — turned out to be the one that did not survive.

Dominant language
Python
Stars
17
Forks
11
Avg merge
5d 19h
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from twilio/twilio-agent-connect-python

All issues in twilio/twilio-agent-connect-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.