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.
Metadata
Release files for piopiy-agent 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| piopiy_agent-1.2.1.tar.gz | 21.1 kB | Without provenance | Details for piopiy_agent-1.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| piopiy_agent-1.2.1-py3-none-any.whl | Python 3 | none | any | Details for piopiy_agent-1.2.1-py3-none-any.whl |
Total release size: 41.8 kB
Release files / piopiy_agent-1.2.1.tar.gz
| Download URL | piopiy_agent-1.2.1.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
141d97489407ce2f0532f34826c2eb9fccaa6e09a2fda8b182bced27f953bbf8
|
|
BLAKE2b-256 checksum How to use checksums |
3ed7bf185d41ad2f5e967b39cc98bdffedaaa69370e969a5c18107271058badf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Release files / piopiy_agent-1.2.1-py3-none-any.whl
| Download URL | piopiy_agent-1.2.1-py3-none-any.whl |
|---|---|
| Size | 20.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc5cc883a07abc6f5ad075609f77d4451a532530095a098e535635a3a90a3fe8
|
|
BLAKE2b-256 checksum How to use checksums |
d25540f75301b37eb96467dfdb1797d30014950a147c15fae40c325b265a9620
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Security for piopiy-agent 1.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.