Skip to main content

Egma SDK for livekit Python agents

This SDK connects your livekit agent to egma for simulation testing and production monitoring. It records the agent's POV during simulations and lets egma inject mock tools.

We need to do four things to set it up.

1. Install the SDK

Install the latest compatible release in the repo where your livekit worker runs. Use the package manager the repo already uses.

pip install --upgrade egma

For a repo using uv:

uv add --upgrade egma

The SDK supports Python 3.11 or newer and livekit-agents>=1.6.6,<1.9, including LiveKit 1.8. It uses OpenAI Python 2. Check compatibility with the worker's existing dependencies before upgrading and keep the resolved versions in the repo's lockfile.

2. Setup the worker's environment

Use an egma API key scoped to the project you want to send data to. You can create it through the CLI or the UI.

  • CLI: from a repo with a logged-in egma CLI and the right project in egma/config.yaml, run the command below. Use egma login if you need to sign in, and egma init if the repo does not have a project setup yet.

    egma project api-key create --name livekit-worker
    
  • UI: open your project in egma, go to Settings → API keys, enter a name, select your project under Scope, and click Create key.

Copy the key when it is shown. The secret is shown once, and the CLI does not save it.

Set these values in the worker's environment:

EGMA_URL=https://api.egma.ai
EGMA_API_KEY=<your project API key>

For self-hosted egma, use your egma API URL. The worker must be able to reach it. Put the key in the worker's secret store or a gitignored environment file. For a cloud worker, set it in the deployed environment as well.

3. Add the integration

There are two functions depending on what you want to setup.

A. Simulation testing

Call and await simulation(agent, ctx, session) after creating the agent and session, before session.start. Add this around the existing start call in your job entrypoint:

from egma import simulation

await simulation(agent, ctx, session)
await session.start(agent=agent, room=ctx.room)

This is required for every voice and text simulation, even when the test has no mock tools. It sends the agent's traces to the simulation and lets egma answer the tools named under ## Mock tools in the test. Other tools run their real implementations and are recorded too.

The SDK recognises simulation rooms by the egma-sim- prefix. In other rooms, simulation does nothing. Keep that prefix reserved for egma simulations.

For text simulations, disable audio and transcription pacing in egma-sim-chat- rooms. Use this start call, keeping your normal voice settings in the other branch:

from livekit.agents import room_io

is_egma_chat = ctx.job.room.name.startswith("egma-sim-chat-")
options = (
    room_io.RoomOptions(
        audio_input=False,
        audio_output=False,
        text_output=room_io.TextOutputOptions(sync_transcription=False),
    )
    if is_egma_chat
    else room_io.RoomOptions()
)

await session.start(agent=agent, room=ctx.room, room_options=options)

Keep the await simulation(...) call before this start call. Turn off any separate audio publishers in the text branch too.

If the worker cannot complete the handshake with egma, simulation raises NotReported. Fix the setup before starting the session. If a mocked tool cannot reach egma during a simulation, that tool errors instead of calling the real backend.

B. Production monitoring

Call monitor(ctx) at the start of the job entrypoint, before ctx.connect and session.start:

from egma import monitor

monitor(ctx)

It sends production traces to egma Monitoring. It does nothing in simulation rooms.

If you want both testing and monitoring, add both calls: monitor(ctx) at the start of the entrypoint, then await simulation(agent, ctx, session) before the session starts. Both use the same environment settings.

The SDK adds egma to a compatible existing OpenTelemetry provider. Keep LiveKit's default of one job per process, so each job's traces stay attached to its own room.

4. Run the updated worker and verify

For simulations, register the agent and a connection in egma if you have not already done so. Start the updated worker with an explicit agent_name matching that connection. Supply the job dispatch metadata your worker needs for startup.

Keep a local worker running during tests. To use a cloud worker, deploy the SDK changes and environment settings there first. A successful local run does not deploy those changes.

  • Testing: run a simulation, wait for it to finish, and check that it completed with the agent's POV. If the agent calls a mocked tool, check its recorded arguments and answer too.
  • Monitoring: make a production conversation and check that it appears in egma Monitoring.

If no worker joins, check the worker process and agent name. If the handshake fails, check the SDK call and room connection. If traces are missing, check the project key, EGMA_URL, and the worker's export logs.

License

Apache-2.0. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

egma-0.3.1.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

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

egma-0.3.1-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file egma-0.3.1.tar.gz.

File metadata

  • Download URL: egma-0.3.1.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for egma-0.3.1.tar.gz
Algorithm Hash digest
SHA256 b381d523cfa98a4165054a829b3c714e18929b40a6f132f68a58753e63755984
MD5 0e765c6c3a093798b9a5cca94923e172
BLAKE2b-256 26bc35c9acaddb1c963342bab3c425dfe01268beb6859f09dfe09435f59e7f62

See more details on using hashes here.

Provenance

The following attestation bundles were made for egma-0.3.1.tar.gz:

Publisher: release-python-sdk.yml on egma-ai/egma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file egma-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: egma-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for egma-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b3da9a5b80ea5ab4b7f4e78176bb8d5e307e697e3ffdf02b6021a3af298f94a7
MD5 a4eaef0e194c00e5643cd3050ccbb7cf
BLAKE2b-256 f0c17b25447424aaa3091bb64638041f37419bad4bf8032334fb689779990e89

See more details on using hashes here.

Provenance

The following attestation bundles were made for egma-0.3.1-py3-none-any.whl:

Publisher: release-python-sdk.yml on egma-ai/egma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

This release

0.3.1 This release

2 files

0.3.0

2 files

0.2.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