Skip to content

feat(simulate): sip_inbound_trunk_id transport field for carrier pinning - #59

Open
azain-commits wants to merge 2 commits into
feat/platform-scenarios-livekit-sipfrom
feat/telnyx-provider
Open

feat(simulate): sip_inbound_trunk_id transport field for carrier pinning#59
azain-commits wants to merge 2 commits into
feat/platform-scenarios-livekit-sipfrom
feat/telnyx-provider

Conversation

@azain-commits

Copy link
Copy Markdown

Summary

Adds TelephonyTransport.sip_inbound_trunk_id so a sip_inbound run can pin the leased carrier pool trunk (e.g. a Telnyx pool) instead of inheriting the worker's default LIVEKIT_INBOUND_TRUNK_ID. The SDK stays carrier-blind — it receives trunk ids / E.164 / dispatch-rule names, never "twilio"/"telnyx" logic. Backward compatible: the field is optional and defaults to None, so existing runs are unchanged. Part of a 3-repo Telnyx effort (companion PRs in future-agi and livekit-infra).

What changed

  • agent/definition.py — new optional sip_inbound_trunk_id field on TelephonyTransport; validator forbids it on sip_outbound and web transports (webrtc/vapi_websocket/retell_webcall).
  • simulation/engines/livekit.py_ensure_sip_inbound_dispatch now:
    • prefers transport.sip_inbound_trunk_id over the LIVEKIT_INBOUND_TRUNK_ID env;
    • when reusing a named dispatch rule, validates the rule's trunk_ids contain the pinned trunk (raises sip_inbound_rule_trunk_mismatch otherwise) — so a stale/other-carrier rule of the same name can't route onto the wrong trunk;
    • falls back to the env only when neither a dispatch rule nor an explicit trunk id is set (self-provision path).
  • endpoints/profiles.pyLIVEKIT_INBOUND_TRUNK_ID is required only when neither a dispatch rule nor an explicit inbound trunk id is present.

Why

The hosted runner leases a carrier-specific inbound pool trunk per run; without a way to pin it, a sip_inbound run falls back to the worker's ambient inbound trunk (one carrier). A neutral transport field keeps the SDK provider-agnostic while letting the platform select the trunk per run and supporting concurrent carriers.

Tests

  • SDK compiles; TelephonyTransport validation covered by the model validator.
  • tests/runtime/test_livekit_engine.py + tests/test_voice_simulation.py: no new failures — the 5 failing engine tests (test_managed_case_dispatches_..., test_sip_outbound_dials_..., 3× test_web_bridge_joins_...) are pre-existing (incomplete mocks / SIP infra), confirmed identical on the branch tip with these changes stashed.

Pre-existing issues (not introduced here)

  • The 5 test_livekit_engine.py failures above pre-date this PR (verified via stash-baseline).

Backward compatibility

  • sip_inbound_trunk_id is optional (None default). With no dispatch rule and no trunk id, behaviour is exactly as before (env-driven self-provision).

Add TelephonyTransport.sip_inbound_trunk_id so a sip_inbound run can pin the
leased carrier pool trunk (e.g. a Telnyx pool) instead of inheriting the
worker's default inbound trunk.

- definition.py: new optional field + validator (forbidden on sip_outbound and
  web transports).
- engines/livekit.py: _ensure_sip_inbound_dispatch prefers the explicit trunk;
  when reusing a named dispatch rule it validates the rule's trunk_ids bind it;
  falls back to LIVEKIT_INBOUND_TRUNK_ID only when neither a rule nor a trunk id
  is set.
- endpoints/profiles.py: require LIVEKIT_INBOUND_TRUNK_ID only when neither a
  dispatch rule nor an explicit inbound trunk id is present.

The SDK stays carrier-blind — it receives trunk ids / E.164 / rule names, never
"twilio"/"telnyx" logic.
@azain-commits

Copy link
Copy Markdown
Author

Telnyx provider — 3-repo PR set:

Suggested review/merge order: livekit-infra → agent-learning-kit → future-agi.

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.

1 participant