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 grpc.piopiy.com:50051
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.0.0.tar.gz (14.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.0.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: piopiy_agent-1.0.0.tar.gz
  • Upload date:
  • Size: 14.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.0.0.tar.gz
Algorithm Hash digest
SHA256 fd5ded72b470d14dadd81ef800265d53e139c70bf023069b0903b10e47299251
MD5 d1e8208a6865f00919dd3af6890bb08b
BLAKE2b-256 b7d9f0be9f7f0ebfa1e47aa0144d48b43c813199caa69c0eced9d961d62b3539

See more details on using hashes here.

File details

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

File metadata

  • Download URL: piopiy_agent-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8bdc7aeedfd66deb14f00912cd3f0447ca31b010c07fc0f4ec6296f37878889d
MD5 310b50395ddaba83fa79a5d37e8a070a
BLAKE2b-256 754d1ec65bb621b09e80064ec69593d892c7bb0d62fbb1d06c7ecd3a17ed56c1

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

This release

1.0.0 This release

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