Add Telnyx media streaming plugin#594
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughTelnyx support was added across the repository. The plugin now includes audio conversion, call registry, and media stream APIs, workspace and package metadata were updated, example helpers now handle setup, validation, and webhook verification, inbound and outbound FastAPI examples were added, and the README and test suites were updated. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2514d5a1-b09e-4c2e-b410-bff2f77ec127
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (12)
README.mdagents-core/pyproject.tomlplugins/telnyx/README.mdplugins/telnyx/py.typedplugins/telnyx/pyproject.tomlplugins/telnyx/tests/test_audio.pyplugins/telnyx/tests/test_telnyx.pyplugins/telnyx/vision_agents/plugins/telnyx/__init__.pyplugins/telnyx/vision_agents/plugins/telnyx/audio.pyplugins/telnyx/vision_agents/plugins/telnyx/call_registry.pyplugins/telnyx/vision_agents/plugins/telnyx/media_stream.pypyproject.toml
|
Hi thank you for your PR, our team is reviewing and will follow up. |
|
@a692570 - can you have a look at the remarks from Coderabbit? |
…e-plugin # Conflicts: # uv.lock
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
plugins/telnyx/vision_agents/plugins/telnyx/call_registry.py (2)
8-8: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winAdopt modern union syntax per coding guidelines.
Coding guidelines specify modern type syntax including
X | Yunions instead ofOptional[X]. Update type hints throughout the file.Example changes
-from typing import Any, Callable, Coroutine, Optional, TYPE_CHECKING +from typing import Any, Callable, Coroutine, TYPE_CHECKING - webhook_data: Optional[dict[str, Any]] = None + webhook_data: dict[str, Any] | None = None - def from_number(self) -> Optional[str]: + def from_number(self) -> str | None:Also applies to: 24-29, 32-32, 40-45, 48-49, 56-56, 62-62, 82-83, 97-97, 114-114
Source: Coding guidelines
27-27:⚠️ Potential issue | 🟠 MajorReplace deprecated
datetime.utcnow()withdatetime.now(timezone.utc)at both sites.
datetime.utcnow()is deprecated as of Python 3.12. Both usages must switch to timezone-aware equivalent.
- Line 27: Replace
datetime.utcnowinstarted_atfield default withlambda: datetime.now(timezone.utc)- Line 53: Replace
datetime.utcnow()inend()method withdatetime.now(timezone.utc)Add
timezoneto the import statement (line 7).Fix
-from datetime import datetime +from datetime import datetime, timezone- started_at: datetime = field(default_factory=datetime.utcnow) + started_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))- self.ended_at = datetime.utcnow() + self.ended_at = datetime.now(timezone.utc)
🧹 Nitpick comments (1)
plugins/telnyx/vision_agents/plugins/telnyx/call_registry.py (1)
8-8: ⚖️ Poor tradeoffMinimize use of
Anytype per coding guidelines.Guidelines state to avoid
Anytype. While webhook_data may genuinely be dynamic JSON, consider whether tighter types are possible forstream_calland method return values. If webhook schema is known, use TypedDict.Also applies to: 24-24, 26-26, 32-32, 62-62, 82-83
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6cd7019c-fa6a-47ba-a543-8f0a6e444ece
📒 Files selected for processing (3)
plugins/telnyx/tests/test_telnyx.pyplugins/telnyx/vision_agents/plugins/telnyx/call_registry.pyplugins/telnyx/vision_agents/plugins/telnyx/media_stream.py
🚧 Files skipped from review as they are similar to previous changes (1)
- plugins/telnyx/vision_agents/plugins/telnyx/media_stream.py
|
@Nash0x7E2 thanks for the nudge. I addressed the CodeRabbit remarks in the latest branch updates. Covered:
Local checks passed:
CodeRabbit is passing now and the PR is no longer conflicted. GitHub still shows the PR as blocked because the fork PR CI workflows appear to need maintainer approval/action. |
|
@a692570 - Great, running the example and will merge. Can ping you here once it's merged and share a link to an integration page on our docs. Feel free to email me if you'd like to collaborate on the integrations docs/page nash@getstream.io |
There was a problem hiding this comment.
Actionable comments posted: 11
🧹 Nitpick comments (3)
plugins/telnyx/examples/telnyx_helpers.py (2)
207-214: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winNarrow the ngrok autodetection exception handling.
This suppresses all runtime errors from the detection block. Catch the expected urllib, timeout, decode, and JSON parsing failures instead.
Proposed change
- except Exception: + except ( + urllib.error.URLError, + TimeoutError, + UnicodeDecodeError, + json.JSONDecodeError, + ): return NoneAs per coding guidelines, "Prefer specific exceptions if they are known."
Source: Coding guidelines
311-314: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace broad cleanup catches with known failure types.
The setup and cleanup paths know their likely failures: Telnyx API, urllib, timeout, JSON, and response-shape errors. Catch those explicitly so programmer errors are not treated as recoverable cleanup failures.
As per coding guidelines, "Prefer specific exceptions if they are known; use
except Exception as eonly when exception type is unclear."Also applies to: 347-361
Source: Coding guidelines
plugins/telnyx/tests/test_examples.py (1)
42-78: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert fake Telnyx state, not recorded call paths.
created_apps,deleted_apps, andupdated_connectionsare call logs. Prefer a fake client that mutates simulated Telnyx resources and assert the resulting app/phone-number state.As per path instructions, "Assert behavior and outputs, not initialization or call paths."
Also applies to: 199-206, 227-234
Source: Path instructions
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e6572ea0-e0e2-4fd5-a8cb-bcdce1d0cec8
📒 Files selected for processing (9)
README.mdTELNYX_EXAMPLE_PLAN.mdplugins/telnyx/README.mdplugins/telnyx/examples/README.mdplugins/telnyx/examples/__init__.pyplugins/telnyx/examples/inbound_call.pyplugins/telnyx/examples/outbound_call.pyplugins/telnyx/examples/telnyx_helpers.pyplugins/telnyx/tests/test_examples.py
✅ Files skipped from review due to trivial changes (4)
- plugins/telnyx/examples/init.py
- TELNYX_EXAMPLE_PLAN.md
- README.md
- plugins/telnyx/examples/README.md
| @@ -0,0 +1,464 @@ | |||
| """Helpers shared by the minimal Telnyx phone examples.""" | |||
|
|
|||
| from __future__ import annotations | |||
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Remove the future annotations import.
This repository explicitly disallows from __future__ import annotations.
As per coding guidelines, "Never use from __future__ import annotations."
Source: Coding guidelines
Move example helpers into the plugin package, verify Telnyx webhook signatures, redact PII from logs, and harden async cleanup in the runnable inbound/outbound examples. Co-authored-by: Cursor <cursoragent@cursor.com>
Nash0x7E2
left a comment
There was a problem hiding this comment.
Addressed latest CodeRabbit feedback on the phone examples: webhook signature verification, PII-safe logging, async cleanup, package imports for tests, and merged latest main.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
plugins/telnyx/vision_agents/plugins/telnyx/example_helpers.py (1)
489-504: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove
Anyfrom the verified webhook parser contract.
dict[str, Any]leaks unchecked JSON through the public helper. Use a concrete JSON payload alias ordict[str, object]with a narrow cast/validation.As per coding guidelines, "Avoid using
Anytype."Source: Coding guidelines
plugins/telnyx/tests/test_examples.py (1)
27-85: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd annotations to the new test helper and test functions.
FakeTelnyxClientmethods and the new tests omit parameter/return annotations; add-> None, parameter types, and concrete dict value types for the fake state.As per coding guidelines, "Use type annotations everywhere."
Also applies to: 170-192, 207-264
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c4f5996b-7794-493b-8808-020c13961a4d
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
README.mdplugins/telnyx/examples/README.mdplugins/telnyx/examples/inbound_call.pyplugins/telnyx/examples/outbound_call.pyplugins/telnyx/pyproject.tomlplugins/telnyx/tests/test_examples.pyplugins/telnyx/tests/test_telnyx.pyplugins/telnyx/vision_agents/plugins/telnyx/example_helpers.py
✅ Files skipped from review due to trivial changes (3)
- plugins/telnyx/pyproject.toml
- README.md
- plugins/telnyx/examples/README.md
🚧 Files skipped from review as they are similar to previous changes (2)
- plugins/telnyx/examples/outbound_call.py
- plugins/telnyx/examples/inbound_call.py
Nash0x7E2
left a comment
There was a problem hiding this comment.
Re-approved after pushing CodeRabbit fixes and merging main. All unit checks are green.
Map invalid timestamps, payloads, and key material to TelnyxWebhookVerificationError instead of leaking parse errors. Co-authored-by: Cursor <cursoragent@cursor.com>
Nash0x7E2
left a comment
There was a problem hiding this comment.
Approved after final webhook verification hardening.
Co-authored-by: Cursor <cursoragent@cursor.com>
Why
Vision Agents already has a Twilio phone plugin and phone examples. Telnyx also supports WebSocket media streaming with PCMU, PCMA, L16, and bidirectional RTP, so this adds a parallel carrier media bridge without changing core agent APIs.
Reference: https://developers.telnyx.com/docs/voice/programmable-voice/media-streaming
Changes
vision-agents-plugins-telnyxas a workspace package and optionalvision-agents[telnyx]extraconnected,start,media,stop,error,mark, anddtmfeventsPcmDataattach_phone_to_callbridge matching the existing Twilio plugin shapeTesting
uv run ruff check plugins/telnyx agents-core/pyproject.toml pyproject.toml README.mduv run ruff format --check plugins/telnyxuv run pytest plugins/twilio/tests plugins/telnyx/testsgit diff --check