For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
  • Introduction
    • Overview
    • Installation
    • Developer Onboarding
    • Quick Start
  • Concepts
    • Architecture
    • Call States and Lifecycle
    • Call Commands
    • Audio Streaming
    • Event Handling
  • Integrations
    • Google GenAI SDK (Gemini Live)
    • Google ADK (Agent Development Kit)
  • Use Cases
    • After-hours Voicemail
    • Appointment Booking
    • Call Monitoring and Coaching
    • Database Lookup
    • Human Escalation
    • Interactive Notifications
  • Reference
    • API Reference
    • Error Handling
    • Advanced Topics
LogoLogo
On this page
  • Control Connection
  • Media Connection
  • What Happens on an Incoming Call
  • Concurrency Model
  • Next Steps
Concepts

Architecture

||View as Markdown|
Was this page helpful?
Previous

Quick Start

Next

Call States and Lifecycle

Built with

The SDK follows a dual-connection architecture:

┌─────────────────────────────────────────────────────┐
│ Your Application │
│ │
│ ┌──────────────────┐ ┌───────────────────────┐ │
│ │ AgenTaoClient │ │ ActiveCall (x N) │ │
│ └────────┬─────────┘ └───────────┬───────────┘ │
│ │ │ │
└────────────┼──────────────────────────┼───────────────┘
│ │
┌────────▼─────────┐ ┌───────────▼───────────┐
│ Control Connection│ │ Media Connection │
│ (Persistent) │ │ (Ephemeral, per call) │
│ │ │ │
│ - Call events │ │ - Audio streaming │
│ - Heartbeat │ │ - Call commands │
│ - Reconnection │ │ - Binary frames │
│ │ │ - Flow control │
└────────┬──────────┘ └───────────┬───────────┘
│ │
└───────────┬───────────────┘
│
┌────────▼────────┐
│ AgenTao Server │
└─────────────────┘

Control Connection

A persistent WebSocket connection that handles:

  • Call events - Incoming call notifications and call state changes
  • Heartbeat - Keeping the connection alive
  • Reconnection - Automatic reconnection on connection loss

Media Connection

An ephemeral WebSocket connection created per call for:

  • Audio streaming - Bidirectional PCM audio
  • Call commands - Per-call operations like answer(), connect(), close(), and disconnect()
  • Binary frames - Raw audio data transport
  • Flow control - Pull-based buffering to prevent jitter

Once an ActiveCall exists, call-specific commands are issued on the media connection, not the control connection.

What Happens on an Incoming Call

When an events.INCOMING_CALL event is received:

  1. The SDK automatically creates an ActiveCall object
  2. The SDK automatically establishes the media connection
  3. Your handler receives the ActiveCall with media already connected

You do not need to manage connections manually. The SDK handles the full lifecycle of both control and media connections.

Concurrency Model

  • Each incoming call is processed in its own dedicated background task
  • Each ActiveCall runs independently in its own asyncio task
  • Control connection heartbeat runs in a separate task
  • Reconnection logic runs in a separate task
  • All operations are non-blocking
  • The SDK automatically manages task lifecycle and cleanup

Next Steps

  • Call States - Understand the call lifecycle and state machine
  • Call Commands - Learn the commands you can issue on a call
  • Audio Streaming - How audio flows between your app and the caller