egma 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
egma-0.2.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Egma
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
egma-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,398 @@
1
+ Metadata-Version: 2.4
2
+ Name: egma
3
+ Version: 0.2.0
4
+ Summary: Test and monitor LiveKit agents with Egma.
5
+ Keywords: livekit,voice,agents,testing,mock tools,egma
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Software Development :: Testing
12
+ Requires-Dist: livekit-agents>=1.6.7,<1.7
13
+ Requires-Dist: openai>=2,<3
14
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.39,<2
15
+ Requires-Dist: opentelemetry-sdk>=1.39,<2
16
+ Requires-Python: >=3.11
17
+ Project-URL: Homepage, https://github.com/egma-ai/egma
18
+ Project-URL: Repository, https://github.com/egma-ai/egma
19
+ Project-URL: Documentation, https://github.com/egma-ai/egma/tree/main/sdks/python#readme
20
+ Description-Content-Type: text/markdown
21
+
22
+ # Egma Python SDK
23
+
24
+ Test a LiveKit agent with mock tools and send its production spans to Egma.
25
+
26
+ The two functions are separate:
27
+
28
+ - `mockable(...)` lets Egma answer tools in an Egma simulation. It does
29
+ nothing in production.
30
+ - `monitor_livekit(...)` sends production LiveKit spans to the
31
+ Monitoring page. It does nothing in an Egma simulation.
32
+
33
+ Calling one function never enables or changes the other.
34
+
35
+ ## Install
36
+
37
+ ```bash
38
+ pip install 'egma>=0.2.0'
39
+ ```
40
+
41
+ `0.2.0` is the floor because it is the first release that knows a
42
+ simulation by the room's name, and so the first that holds on every one of
43
+ the three dispatch paths. An unpinned install can resolve to a release
44
+ that looks in the dispatch metadata instead, where Egma no longer writes
45
+ anything — inert inside a real simulation on all three.
46
+
47
+ For a LiveKit agent on Python 3.11 or newer.
48
+
49
+ ## Production monitoring
50
+
51
+ Open **Monitoring → Start monitoring** and choose **LiveKit**. That page
52
+ shows the same SDK, key, and helper steps below. It is instructions only: a
53
+ LiveKit agent pushes its own spans, so there is nothing to switch on in Egma.
54
+
55
+ Set the Egma API origin and an existing project API key in the agent's
56
+ environment:
57
+
58
+ ```bash
59
+ export EGMA_URL=https://api.egma.ai
60
+ export EGMA_API_KEY=egma_sk_...
61
+ ```
62
+
63
+ For self-hosted Egma, prefer the published API address, such as
64
+ `http://localhost:3100`. The web address also works because Egma forwards
65
+ `/v1/traces` to the API, but the API is one hop shorter. The agent process must
66
+ be able to make HTTP or HTTPS requests to the address you choose.
67
+
68
+ In a customer-hosted worker, set these values through your normal deployment
69
+ secret store. For LiveKit Cloud, place them in a gitignored secrets file and
70
+ apply it to the agent:
71
+
72
+ ```bash
73
+ lk agent update-secrets --secrets-file=.env.monitoring
74
+ ```
75
+
76
+ Use the same file with `lk agent create --secrets-file=.env.monitoring` for a
77
+ new deployment. LiveKit Cloud restarts the agent after a secret update.
78
+
79
+ Call `monitor_livekit` before `AgentSession.start`:
80
+
81
+ ```python
82
+ from egma import monitor_livekit
83
+ from livekit import agents
84
+ from livekit.agents import Agent, AgentSession
85
+
86
+
87
+ async def entrypoint(ctx: agents.JobContext) -> None:
88
+ monitor_livekit(ctx)
89
+ await ctx.connect()
90
+
91
+ agent = Agent(instructions=INSTRUCTIONS, tools=[check_calendar])
92
+ session = AgentSession(stt=..., llm=..., tts=...)
93
+ await session.start(agent=agent, room=ctx.room)
94
+ ```
95
+
96
+ You can pass the same values directly when environment variables are not the
97
+ right configuration source:
98
+
99
+ ```python
100
+ monitor_livekit(ctx, endpoint="https://api.egma.ai", api_key=project_key)
101
+ ```
102
+
103
+ Use the same call for an agent hosted in your cloud and an agent hosted in
104
+ LiveKit Cloud. The helper adds Egma to a compatible OpenTelemetry provider; it
105
+ does not remove LiveKit Cloud observability or another existing span
106
+ processor. It sends spans in batches and flushes the final batch when the
107
+ LiveKit job stops.
108
+
109
+ If this job runs in an Egma simulation room, the helper returns without
110
+ adding a production exporter and says so at `WARNING`. The simulation keeps
111
+ its own trace and does not appear a second time in Monitoring.
112
+
113
+ The helper reads the room's name for that and nothing else. Every Egma
114
+ simulation room is named `egma-sim-…`; a room named anything else gets the
115
+ production exporter. The name arrives with the job, so this decision costs
116
+ no network and happens before `ctx.connect()`.
117
+
118
+ After deployment, open **Monitoring**. Nothing needs to be confirmed in Egma —
119
+ the deployed helper is what sends spans, and the first production conversation
120
+ appears in the list as soon as it arrives.
121
+
122
+ The caller's phone, SIP, or WebRTC entry path does not change this setup. The
123
+ SDK does not guess that path from a LiveKit trace.
124
+
125
+ ### Setup status
126
+
127
+ The helper stops immediately with one direct error when required settings are
128
+ missing or malformed, or when tracer providers conflict. It does not include
129
+ the key in that error.
130
+
131
+ After deployment, Monitoring stays empty until the first trace reaches Egma,
132
+ then lists each production conversation as it arrives. This release uses one-way
133
+ OTLP export. Egma cannot see a DNS, firewall, or network failure inside the
134
+ worker. Check the worker's OpenTelemetry logs and confirm that it can reach
135
+ `EGMA_URL` when nothing appears.
136
+
137
+ ## Simulation mock tools
138
+
139
+ A simulation that reaches your real tools has real side effects: it books
140
+ the appointment, sends the message, charges the card. And a real backend
141
+ only ever shows you the branch its data happens to be on — "the calendar
142
+ is full", "the lookup fails", "the booking API errors" are where voice
143
+ agents die in production, and none of them can be ordered up from a real
144
+ backend on demand.
145
+
146
+ A **mock tool** answers for one of your agent's tools during a
147
+ simulation. It is authored in your Egma project, matched strictly by tool
148
+ name, and its answer may be a value, an error, or either one after a
149
+ declared delay so a mocked backend takes as long as the real one. This
150
+ package is the piece that lives in your own agent's process and lets Egma
151
+ answer.
152
+
153
+ Tools no mock tool covers run their real implementations, untouched.
154
+ Egma's record names which of your tools were covered and which were not,
155
+ so you always know whether a simulation was fully isolated.
156
+
157
+ ### Use
158
+
159
+ One call, after the agent is built and before the session starts:
160
+
161
+ ```python
162
+ from egma import mockable
163
+ ```
164
+
165
+ ```python
166
+ async def entrypoint(ctx: agents.JobContext) -> None:
167
+ agent = Agent(instructions=INSTRUCTIONS, tools=[check_calendar, book_appointment])
168
+ session = AgentSession(stt=..., llm=..., tts=...)
169
+
170
+ await mockable(agent, ctx, session)
171
+
172
+ await session.start(agent=agent, room=ctx.room)
173
+ ```
174
+
175
+ That is the whole simulation integration.
176
+
177
+ ### How it knows it is in a simulation
178
+
179
+ It reads the **room's name** off the job. Every room Egma conducts a
180
+ simulation in is named `egma-sim-…`, and that prefix is fixed. Nothing
181
+ else is read, nothing is asked, and no room is connected to find out.
182
+
183
+ The name is the signal because it is the one that arrives on every
184
+ dispatch path an agent can end up in an Egma room by — whether Egma
185
+ dispatches your worker by name, whether LiveKit walks an unnamed worker
186
+ into the room, and whether your own token endpoint puts the agent there.
187
+ A signal carried by an explicit dispatch arrives on only the first of
188
+ those.
189
+
190
+ In a simulation room, `mockable` connects the job with LiveKit's own
191
+ `JobContext.connect()` if your startup has not already done so, then finds
192
+ Egma among the room's participants: Egma joins as `egma-persona` or
193
+ `egma-persona-<simulation>`. On two of the three dispatch paths your
194
+ agent is in the room **before** Egma, so it waits for that participant,
195
+ for up to 45 seconds and without polling anything outside the room. That
196
+ is a long time to hold an agent before it greets anybody, and it is the
197
+ price of the wait being correct on every dispatch path rather than on one;
198
+ a simulation ordinarily pays a fraction of it. It does not reconnect an
199
+ already-connected room, and it never connects a production room.
200
+
201
+ If nobody by that name arrives, nothing is wrapped, your tools all run
202
+ their own implementations, and the reason is logged at `ERROR`. If two
203
+ participants answer to that name, the exchange is refused for the same
204
+ reason a room with two claimants has no knowable answer — and your tool
205
+ inventory is not sent to either of them.
206
+
207
+ Then `mockable` reports your agent's tools to Egma — names and schemas,
208
+ read off the agent object, so mock authoring starts from your real tool
209
+ names instead of your memory of them — and learns which of them this
210
+ simulation answers for. Calls to those tools go to Egma and come back with
211
+ the authored answer. Every one of them lands on the simulation's record
212
+ with its arguments, its answer, how long it took, and which mock tool
213
+ answered.
214
+
215
+ **In every other room it does nothing at all.** A room your own system
216
+ named — which is every production room — is a room where `mockable`
217
+ returns having touched nothing: no wrapper, no message, no connect. Your
218
+ tools are the same objects, called the same way, with no wrapper between
219
+ them and the model. Zero added latency, by construction rather than by
220
+ care. That property is a test in this package (`tests/test_inert.py`),
221
+ not a promise in this file.
222
+
223
+ Your job's **dispatch metadata is yours**. This SDK writes nothing into it
224
+ and reads nothing out of it — not one key, in any room, for any purpose.
225
+ Neither does Egma: on every dispatch path, both the room's metadata and
226
+ the dispatch's carry the string configured on the connection, byte for
227
+ byte. `json.loads(ctx.job.metadata)["your_key"]` reads the same thing in a
228
+ simulation that it reads in production.
229
+
230
+ ### Where to call it
231
+
232
+ After the agent object exists and before `session.start`. The report of
233
+ your tools is the first thing said, so an Egma that is not in the room is
234
+ discovered before any tool call rather than half way through a test.
235
+
236
+ Keep one `mockable` call for the initial agent. The SDK follows LiveKit's
237
+ public handoff events and installs the same simulation couriers for each
238
+ selected `Agent` or `AgentTask` before that activity starts. Each handoff
239
+ also extends one cumulative tool census, so Egma's coverage record keeps
240
+ the tools found on earlier agents.
241
+
242
+ ### What a call to a mocked tool does
243
+
244
+ - Goes to Egma over the same LiveKit room. No new endpoint, no new
245
+ credential, nothing new to expose. If needed, `mockable` connects that
246
+ room through the job context before sending the first RPC.
247
+ - Comes back with the authored answer, or raises the authored error as
248
+ the tool's own error, so your agent handles it exactly as it would
249
+ handle a real backend failing.
250
+ - **Falls open** if Egma turns out not to be reachable: your real tool
251
+ runs, and the agent behaves as it would with this package uninstalled.
252
+ - **Never waits forever.** Every branch ends in an answer, an error the
253
+ model can hear, or your own tool running.
254
+
255
+ A tool you attach to the agent *after* calling `mockable` is still
256
+ intercepted on its first call — Egma's answers are held by name. Its
257
+ arguments may be incomplete on the record, and Egma marks that call so
258
+ you can see it.
259
+
260
+ ### Logging
261
+
262
+ Everything this package says goes to the `egma` logger. It is worth
263
+ having on at `INFO` the first time you wire an agent up: the line after
264
+ the census names how many tools you have and how many Egma answers for.
265
+
266
+ `ERROR` is reserved for a simulation that could not be isolated and can
267
+ be acted on — no Egma participant arrived in a simulation room, two
268
+ participants claimed to be Egma, or the two halves do not speak the same
269
+ version of the exchange. None of those lines is reachable in a production
270
+ room.
271
+
272
+ ## Before you install anything: the interim recipe
273
+
274
+ You can get isolation today with no Egma code at all, using LiveKit's own
275
+ `mock_tools` and a guard you write yourself:
276
+
277
+ ```python
278
+ from livekit.agents import mock_tools
279
+
280
+
281
+ def in_a_simulation(ctx: agents.JobContext) -> bool:
282
+ return ctx.job.room.name.startswith("egma-sim-")
283
+
284
+
285
+ async def entrypoint(ctx: agents.JobContext) -> None:
286
+ await ctx.connect()
287
+ agent = Agent(instructions=INSTRUCTIONS, tools=[check_calendar])
288
+ session = AgentSession(stt=..., llm=..., tts=...)
289
+
290
+ if in_a_simulation(ctx):
291
+ mock_tools(
292
+ type(agent),
293
+ {"check_calendar": lambda day: "No free slots on that day."},
294
+ session=session,
295
+ )
296
+
297
+ await session.start(agent=agent, room=ctx.room)
298
+ ```
299
+
300
+ A room your own system named means the guard is false and nothing is
301
+ wrapped. Note where that safety comes from, because it is not where
302
+ `mockable`'s comes from: this guard fires on a prefix being *present*
303
+ rather than on Egma being *absent*. So it is true in any room whose name
304
+ begins `egma-sim-`, including one Egma is not in — `mockable` waits for
305
+ Egma's participant and gives up out loud, while this guard has nobody to
306
+ wait for and simply mocks. Refuse that prefix wherever your own side mints
307
+ production tokens, or a production room named to look like a simulation
308
+ runs your canned answers against a live caller.
309
+
310
+ **Write the guard on the room name, and not on `egmaIdentity` in
311
+ `ctx.job.metadata`.** That key is in no simulation room at all: your
312
+ dispatch metadata is yours, and Egma writes nothing into it on any
313
+ dispatch path. A guard on it does not raise — it quietly fails to fire,
314
+ and every real tool it was meant to hold back runs inside a simulation.
315
+
316
+ What it cannot do is the rest of the job. One canned world for every
317
+ test, so you cannot write "the calendar is full" as a *test* — you would
318
+ be editing your agent's source to change a test's data. Nothing about
319
+ those calls reaches Egma's record: no arguments, no answers, no timings,
320
+ no coverage stamp, so graders that read tool facts have nothing to read.
321
+ No declared delay, so latency numbers from a mocked run flatter you.
322
+
323
+ **And the honest caveat: that guard couples your agent's source to how
324
+ Egma announces itself.** The room-name prefix is a stated contract rather
325
+ than an implementation detail, so it is the safe thing to key off — but
326
+ the *rest* of the mechanism is not: where Egma sits in the room, what
327
+ it is called, how long it takes to arrive, and what a room with two
328
+ claimants means are all Egma's to evolve. That is precisely what
329
+ `mockable` exists to own, and your side stays one line.
330
+
331
+ Use the recipe as the bridge, not as the small tier.
332
+
333
+ ## Compatibility
334
+
335
+ The `egma-sim-` room-name prefix is a stated contract, not an internal
336
+ detail. Every room Egma opens for a simulation begins with it, on every
337
+ dispatch path, and it is there to be relied on and to be allowlisted in
338
+ a token endpoint. This SDK keys its whole simulation/production decision
339
+ off it.
340
+
341
+ Every Egma deployment names its rooms that way, so this package works
342
+ against a self-hosted Egma on whatever schedule its owner upgrades it.
343
+ Nothing else is consulted — in particular, neither metadata channel,
344
+ which carries your own configured JSON and nothing of Egma's.
345
+
346
+ This package pins `livekit-agents` to one minor version
347
+ (`>=1.6.7,<1.7`), and that is deliberate. Interception uses LiveKit's
348
+ testing API. Monitoring also reads LiveKit's current dynamic tracer
349
+ provider because the public telemetry API has a setter but no getter.
350
+ The fixture and live tests verify both seams before the supported range
351
+ changes.
352
+
353
+ The package also keeps the OpenAI Python package on major version 2.
354
+ LiveKit Agents 1.6 does not support OpenAI 3.
355
+
356
+ `mock_tools` writes into a side table LiveKit keeps per session. It does
357
+ not touch your agent, your agent's class, or your tool registry, and the
358
+ model keeps seeing your real tool schemas throughout. Never calling it
359
+ leaves everything byte for byte as it was, which is what makes the inert
360
+ path literal.
361
+
362
+ If that API ever moves, the documented fallback is
363
+ `Agent.update_tools(...)` with `function_tool(raw_schema=...)` wrappers
364
+ built from the real tools' schemas. It is a heavier mechanism — it takes
365
+ responsibility for schema fidelity, for the real implementations, and for
366
+ re-wrapping after a handoff — which is exactly why it is the fallback and
367
+ not the mechanism.
368
+
369
+ ## Developing this package
370
+
371
+ The toolchain is [uv](https://docs.astral.sh/uv/).
372
+
373
+ ```bash
374
+ uv sync
375
+ uv run ruff check src tests
376
+ uv run pytest
377
+ ```
378
+
379
+ The normal suite is hermetic: no LiveKit server, no project, and no external
380
+ network. One monitoring test uses a local HTTP collector. One live test skips
381
+ visibly when the environment is silent, naming what it needs. To run it, point
382
+ it at a LiveKit project:
383
+
384
+ ```bash
385
+ TEST_LIVEKIT_URL=wss://... \
386
+ TEST_LIVEKIT_API_KEY=... TEST_LIVEKIT_API_SECRET=... \
387
+ TEST_MODEL_API_KEY=... \
388
+ uv run pytest tests/test_live_mockable.py -v
389
+ ```
390
+
391
+ Each name falls back to the plain one the tool's own CLI reads —
392
+ `LIVEKIT_URL`, `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET`, `OPENAI_API_KEY`
393
+ — so one environment serves this and whatever else you run beside it.
394
+ `TEST_MODEL_NAME` picks the model; it defaults to `gpt-4o-mini`.
395
+
396
+ ## License
397
+
398
+ Apache-2.0, with the rest of Egma.