Skip to content

fix(simulate): move Retell web calls to the v3 gateway (TH-8763, stacked from #295) - #302

Open
khushalsonawat wants to merge 3 commits into
feat/TH-8804-source-subfolderfrom
fix/TH-8763-retell-v3-stacked
Open

khushalsonawat wants to merge 3 commits into
feat/TH-8804-source-subfolderfrom
fix/TH-8763-retell-v3-stacked

Conversation

@khushalsonawat

@khushalsonawat khushalsonawat commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

This is Dileep's commit 5acc227 from #295, cherry-picked onto the #225 branch (feat/TH-8804-source-subfolder) with him as author. #295 itself is unchanged.

Description

Retell no longer accepts POST /v2/create-web-call, so every Retell voice web call failed to start. Dileep's commit creates calls through Retell's v3 gateway and connects over WebRTC (aiortc). Its errors carry the HTTP status.

Type of Change

  • Bug fix

Changes

  • Dileep's commit (0fb53e6, cherry-picked from 5acc227):
    • src/fi/simulate/simulation/bridge/retell.py: v3 web-call creation and a WebRTC connection;
    • src/fi/alk/harness/call_runner.py: the web-call URL;
    • src/fi/simulate/agent/definition.py: the Retell target config;
    • pyproject.toml: adds aiortc>=1.9,<2;
    • uv.lock;
    • tests/test_retell_webcall_bridge.py.
  • Added here (66200d5): the SDK smoke job now runs tests/test_retell_webcall_bridge.py. That job is the only place aiortc is installed, and before this it didn't run the bridge tests.
  • Added here (8d418bd), from the change review:
    • only the agent-track wait reads as a track timeout; a stalled create or session POST gets its own code;
    • connect() returns once the peer connection is connected, and caller audio queued before that is dropped;
    • 30 s with no agent audio raises retell_webcall_agent_audio_timeout, where it used to end the call as a hangup. The audio bridge now passes a provider's audio error on instead of swallowing it. Only the Retell and Vapi profiles use this bridge, and Vapi's connector doesn't raise there, so no other provider's call ends differently;
    • the v2 URL upgrade keeps the configured host and applies to every RetellTargetConfig;
    • the bridge package loads aiortc only when the Retell connector is used, so a Vapi or LiveKit run doesn't need it;
    • ConnectorConfig keeps the API key out of its repr;
    • tests for each, plus pacing, the control channel's order, buffer overflow, the request timeout, a closed connection and a media stream error.

Known limits

  • The hosted sandbox template still lacks aiortc. Hosted Retell calls need the template rebuilt with it. That waits for the next template rebuild, which waits on future-agi#3954 and the token.
  • Hosted egress may block WebRTC media. The hosted egress allowlist (hosted_harness_gateway.py:1188 in future-agi) lists HTTP hosts only. Media to Retell's ICE/TURN servers may need allowing there. Check this at the template rebuild.
  • av is imported but not declared; it comes in through aiortc and livekit-agents. Declaring it needs a re-lock with network. CI installs with pip, so it tests av 19.0.2, while the lock pins 17.1.0.
  • A Retell agent-audio timeout shows in the case report as stop_reason: provider_disconnected, with the code only in the log. Its cleanup is recorded as failed (bridge_close:RetellWebCallError), as the watchdog's errors already are. Nothing reads those fields.
  • On a provider error, the last second or so of agent audio isn't played into the room.
  • A proxy with a path prefix keeps it for the create call, but not for the session call. That was already so in the original commit.
  • A cancel that lands after the session POST succeeds, but before the session URL is stored, sends no DELETE. Retell then times the call out. That was already so before the v3 move.
  • The pacing test is not strict: its floor accepts a pacer that sleeps too little, and a CI stall of 20 ms or more between two reads can fail it. A fake clock would make it exact.
  • The lockfile was auto-merged onto this branch. uv lock --check --offline passes (295 packages). The aiortc split, 1.15.0 below Python 3.11 and 1.16.0 from 3.11, is the same as in fix(simulate): move Retell web calls to the v3 gateway #295's lock.

Testing

  • The bridge tests ran in this PR's SDK smoke job, on CI's Python 3.12. They did not run locally: that would need a new environment with aiortc downloaded.
  • Change review: two reviewers, including whether any log line or error message carries the web-call token or a credential. Both were CLEAR. Their Mediums are fixed in 8d418bd, and a third reviewer checked those fixes alone (CLEAR). After that check cleared, three Lows were fixed by hand (a TYPE_CHECKING import, the bridge-error test's stub, and the pacing test's lower bound); one more reviewer checked those alone: CLEAR.

Related Issues

Refs: TH-8763

cdileep23 and others added 2 commits November 12, 2026 00:50
Retell refuses POST /v2/create-web-call, so every Retell voice call failed
to start. Create v3 calls and connect over WebRTC; errors carry the HTTP status.

(cherry picked from commit 5acc227)
Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
…(TH-8763)

The smoke job is the only place aiortc is installed, and it didn't run
tests/test_retell_webcall_bridge.py, so the v3 web-call tests never ran
in CI.

Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
@khushalsonawat khushalsonawat self-assigned this Nov 11, 2026
…H-8763)

Fixes from the change review of the v3 web-call move:
- only the agent-track wait reads as a track timeout; a stalled create or
  session POST has its own code;
- connect() returns once the peer connection is connected, and caller audio
  queued before that is dropped;
- 30 s with no agent audio raises retell_webcall_agent_audio_timeout instead
  of ending the call as a hangup, and the bridge passes a provider's audio
  error on instead of swallowing it;
- the v2 URL upgrade keeps the configured host and applies to every
  RetellTargetConfig;
- the bridge package loads aiortc only when the Retell connector is used;
- ConnectorConfig keeps the API key out of its repr.

Tests cover each, plus pacing, the control channel's order, buffer overflow,
the request timeout, a closed connection and a media stream error.

Refs: TH-8763
Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants