refactor(channels): Deduplicate send_response across messaging channels - #94
Merged
Conversation
SMS, RCS, WhatsApp, and Chat each reimplemented an almost identical send_response (validation, ActionChannelSettings building, Actions API call, logging). Consolidate the shared logic into MessagingChannel, with channel_settings construction as the one real per-channel override point (chat requires channel_id; others treat it as optional). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Refactors messaging channels to remove duplicated send_response() logic by centralizing it in MessagingChannel, while keeping per-channel customization via _build_channel_settings() (notably: Chat requires channel_id).
Changes:
- Introduces shared
MessagingChannel.send_response()and default_build_channel_settings()implementation. - Removes per-channel
send_response()duplicates from SMS/RCS/WhatsApp/Chat; Chat overrides_build_channel_settings()to requirechannel_id. - Updates tests to expect standardized error messages using wire channel names.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tac/channels/messaging.py | Adds shared send_response() and default ActionChannelSettings construction hook |
| src/tac/channels/chat.py | Replaces custom send_response() with _build_channel_settings() requiring channel_id |
| src/tac/channels/sms.py | Removes duplicated send_response() implementation in favor of base behavior |
| src/tac/channels/rcs.py | Removes duplicated send_response() implementation in favor of base behavior |
| src/tac/channels/whatsapp.py | Removes duplicated send_response() implementation in favor of base behavior |
| tests/test_chat_channel.py | Updates assertion to match standardized error message |
| tests/test_whatsapp_channel.py | Updates assertion to match standardized error message |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ing channels Messaging channels (SMS/RCS/WhatsApp/Chat) only support a single complete string response, unlike the Voice channel which supports streaming. Document why the type-annotated AsyncGenerator branch is rejected at runtime, addressing PR review feedback.
ryanrouleau
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SMS, RCS, WhatsApp, and Chat each had a nearly-identical
send_response()implementation (type/session/participant validation, buildingActionChannelSettings, constructing theSendMessageActionRequest, callingcreate_action, and logging). This consolidates the shared logic intoMessagingChannel.send_response()insrc/tac/channels/messaging.py, leaving one overridable hook —_build_channel_settings()— for the one real behavioral difference: Chat requireschannel_id(raisesRuntimeErrorif missing), while SMS/RCS/WhatsApp treat it as optional.Net effect: ~370 lines of duplicated logic removed from
sms.py/rcs.py/whatsapp.py/chat.py, with no changes to public API signatures.Behavior changes (minor, non-functional):
SMS,RCS,WHATSAPP,CHAT) instead of a mix of that and a display form (WhatsApp,Chat) — two test assertions were updated to match.to_addressandchannel_idfor every channel (previously Chat only loggedchannel_id, others only loggedto_address).Also clarified the
send_response()docstring: the shared base interface's type annotation allowsstr | AsyncGenerator[...](to accommodate the Voice channel, which supports streaming), but messaging channels only ever acceptstrand raiseTypeErrorfor anything else, since they send a single complete message via the Conversation Orchestrator Send API and have no streaming path.How to test
make check(lint + type-check + test) — all passing locally.send_response()call signature or contract; existing channel tests (test_sms_channel.py,test_rcs_channel.py,test_whatsapp_channel.py,test_chat_channel.py) cover this path.SDK Parity