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

Abierto
#136 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 5 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
50/100
Tipo de issue
Documentación
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
17
Forks
11
Merge medio
5 d 19 h
PR fusionados (30 d)
6

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de twilio/twilio-agent-connect-python

Todos los issues de twilio/twilio-agent-connect-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.