piopiy-agent
Connect a voice agent to the TeleCMI telephony platform.
pip install piopiy-agent
No protoc. No grpcio-tools. No protobuf version clash. The stubs ship
pre-generated, built against an old runtime, so they load under whatever
protobuf your agent framework pins.
Check your credentials
export PIOPIY_AGENT_ID=agent_42
export PIOPIY_TOKEN=eyJhbGciOi...
python -m piopiy_agent
A .env in the working directory is picked up too, if python-dotenv is
installed.
OK registered in 41ms
accept_deadline_ms 400
Do this before anything else. It separates "my credentials are wrong" from "my agent code is wrong", which otherwise look identical.
Take calls
import asyncio
from piopiy_agent import PiopiyWorker
worker = PiopiyWorker(max_sessions=10)
@worker.on_job
async def handle(job):
# Everything needed to join is on the job. The token is pre-minted and
# scoped to this one room - you never hold LiveKit admin credentials.
await my_agent.join(job.livekit_url, job.access_token, job.room_name)
# ONLY once you are actually in the room. The caller is bridged in on
# the strength of this call.
await job.accept()
await my_agent.run() # returns when the call ends
asyncio.run(worker.run())
job.call carries from_number, to_number, direction, call_uuid and any
whitelisted SIP headers.
The one rule
Accept only after you are in the room.
TeleCMI bridges the caller the moment you accept. Accept on receiving the job and the caller arrives in an empty room and hears silence — which is the single failure this whole design exists to prevent.
You have job.deadline_ms (400 by default) to join. job.remaining_ms tells
you what is left.
If you join late, job.accept() returns False and sends nothing: the call
has gone to another instance, and a late accept would put two agents on one
call. Leave the room when you see False.
What the SDK handles so you do not have to
- Registration and reconnects. A TeleCMI restart ends your stream with
CANCELLED, notUNAVAILABLE.CANCELLEDis non-retryable by gRPC convention, so a client reconnecting only onUNAVAILABLEsilently stays down after every deploy. This reconnects on any end of stream, with backoff. - Serving late. Reports
NOT_SERVINGuntil one call has actually been accepted. A gRPC channel opens long before a Python process can reach a media server, and a fresh instance reports zero active sessions — so it looks like the best candidate exactly when it is least able to answer. - Capacity. Stops accepting at
max_sessionsand rejects withAT_CAPACITY. Be honest with this number: a worker that takes more than it can serve produces dead air, where a fast rejection costs TeleCMI 2ms and it moves on. - Heartbeats and status.
- A handler that returns without accepting is rejected rather than left to time out — the caller is listening to silence for every millisecond of it.
Configuration
Constructor arguments, or environment:
TELECMI_AGENT_ID |
from the dashboard |
TELECMI_TOKEN |
from the dashboard |
PIOPIY_REGISTER |
default register.piopiy.com (host only, gRPC over TLS); host:port for a private register |
PIOPIY_TLS |
false only against a local register |
TELECMI_INSTANCE_ID |
defaults to hostname-pid |
Why the stubs are vendored
Generated protobuf code carries the version it was built with, and the runtime
refuses to load gencode newer than itself. pip install grpcio-tools
resolves protobuf 7.x, while agent frameworks commonly pin 5.x — so generating
locally produces stubs your own environment cannot import:
VersionError: gencode 7.35.1 runtime 5.29.6
The error names protobuf, not gRPC and not TeleCMI, which is what makes it expensive to diagnose. Shipping stubs built against an old runtime removes the problem: protobuf accepts a runtime newer than the gencode, never older.
Verified against protobuf 4.25, 5.29 and 7.36.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file piopiy_agent-1.2.1.tar.gz.
File metadata
- Download URL: piopiy_agent-1.2.1.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
141d97489407ce2f0532f34826c2eb9fccaa6e09a2fda8b182bced27f953bbf8
|
|
| MD5 |
e338d86febd63cc8b548fe4329937bcc
|
|
| BLAKE2b-256 |
3ed7bf185d41ad2f5e967b39cc98bdffedaaa69370e969a5c18107271058badf
|
File details
Details for the file piopiy_agent-1.2.1-py3-none-any.whl.
File metadata
- Download URL: piopiy_agent-1.2.1-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc5cc883a07abc6f5ad075609f77d4451a532530095a098e535635a3a90a3fe8
|
|
| MD5 |
2c98942e0127ae1059e4f50aeed893d2
|
|
| BLAKE2b-256 |
d25540f75301b37eb96467dfdb1797d30014950a147c15fae40c325b265a9620
|