Skip to main content

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, not UNAVAILABLE. CANCELLED is non-retryable by gRPC convention, so a client reconnecting only on UNAVAILABLE silently stays down after every deploy. This reconnects on any end of stream, with backoff.
  • Serving late. Reports NOT_SERVING until 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_sessions and rejects with AT_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

piopiy_agent-1.2.0.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

piopiy_agent-1.2.0-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file piopiy_agent-1.2.0.tar.gz.

File metadata

  • Download URL: piopiy_agent-1.2.0.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for piopiy_agent-1.2.0.tar.gz
Algorithm Hash digest
SHA256 3ee107fbca7d6051d23d1d007df168d6dd7ef220fb77a11a46ca3db3423ccada
MD5 1e5534ab1815cfd02cef990ca1c2c614
BLAKE2b-256 073cebe5ab7a2e36e890ea222a2e255b721638dc87511420e4ffd0ceb49e56e7

See more details on using hashes here.

File details

Details for the file piopiy_agent-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: piopiy_agent-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for piopiy_agent-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 193fe67691b73f0186f78f473a06397d8e629e5688f7d6c9b7d4f8601afce961
MD5 0ad559d27ce01a4a8b1a8bb3d1152de9
BLAKE2b-256 bae3584458d655aefdf19917b70f6ba6f9e221b037b466ca0ce5f285abaa8154

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.1

2 files

This release

1.2.0 This release

2 files

1.1.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page