Earful
Deterministic regression tests for Python voice agents built with LiveKit Agents or Pipecat.
A voice agent can sound fine in a demo and still book a table twice or keep talking over the caller. These failures live in timing: an interruption that lands while a tool is running, a write that commits after its caller gave up.
Earful runs a LiveKit AgentSession or a Pipecat pipeline on a virtual clock against a scripted
user, a scripted model, a scripted voice and a fake backend, and records everything that happened
in a ledger. It checks seven contracts against that ledger, searches the timings and
backend faults near your scenario for a run that breaks one, and reduces what it finds to
a small case that replays the same way every time.
A failing test leaves a report: one HTML page with the run as a timeline, the verdict of each contract and every event. The picture is the failure the quickstart below finds. Open that report and select a verdict to see what it rests on, or look at a known defect of livekit-agents 1.5.6 drawn the same way.
The user, the model and the voice are scripted, so a test shows a failure only in behaviour its script models. The quickstart finds a double booking because its scripted model tries a failed tool call again.
For Pipecat, use Python 3.11 or later and pip install "earful[pipecat]". The
Pipecat quickstart
walks through running a greeting in pytest and inspecting its ledger from the command line.
Quickstart
This LiveKit example takes ten minutes on Python 3.10 or later, with pytest installed.
The two files below are in
examples/booking. The output shown is from livekit-agents 1.8.13.
pip install "earful[livekit]"
[livekit] installs livekit-agents alongside, within the supported version range.
1. An agent. This one takes restaurant bookings. It is handed the service it books
with and knows nothing of Earful. Save it as agent.py.
"""A restaurant booking agent, as an application would write it. Nothing here knows of
Earful: the agent is handed the service it books with."""
from typing import Protocol
import livekit.agents as lk
class Reservations(Protocol):
"""The reservation service, as the agent uses it."""
async def create(self, party_size: int, *, idempotency_key: str | None = None) -> str:
"""Book a table and return the confirmation number."""
...
class BookingAgent(lk.Agent):
def __init__(self, reservations: Reservations) -> None:
super().__init__(instructions="You take reservations for a restaurant.")
self._reservations = reservations
@lk.function_tool
async def create_reservation(self, party_size: int) -> str:
"""Book a table for tonight.
Args:
party_size: Number of guests
"""
confirmation = await self._reservations.create(party_size)
return f"Booked. Confirmation {confirmation}."
2. A test. A stand-in for the reservation service, a scripted model, one user turn,
and two tests. Save it as test_booking.py.
"""One conversation with the booking agent, run as written and then searched."""
from agent import BookingAgent
from earful import effect
from earful.livekit import (
Case,
Intent,
ScriptedModel,
UserSpeech,
tool_failed,
tool_succeeded,
user_ever_said,
)
class FakeReservations:
"""Stands in for the reservation service. A booking is one write to Earful's backend,
which a search makes slow, failing or lossy."""
async def create(self, party_size: int, *, idempotency_key: str | None = None) -> str:
return await effect("book-table", {"party_size": party_size}, key=idempotency_key)
# The scripted model. It books when asked, tries once more if the tool fails, and tells
# the user the table is booked only after a call that succeeded.
BOOK = ("create_reservation", {"party_size": 4})
model = (
ScriptedModel()
.when(tool_succeeded(), say="Your table for four is booked.", claims=["book-table"])
.when(
tool_failed() & (lambda context: len(context.tool_results) >= 2),
say="Sorry, I could not book that. Please call the restaurant.",
)
.when(tool_failed(), say="One moment, let me try that again.", call=BOOK)
.when(user_ever_said("table"), say="Let me book that for you.", call=BOOK)
.otherwise(say="How can I help?")
)
def booking() -> Case:
return Case(
name="booking",
agent=lambda: BookingAgent(FakeReservations()),
speeches=[UserSpeech(start=0.5, end=2.5, transcript="A table for four tonight, please.")],
policy=model,
intents=[Intent("book-table")], # what the user wants done, once
backend_mode="keyed", # the service honours an idempotency key, if it is sent one
)
def test_the_conversation_as_written(earful):
earful.run(booking).assert_contracts()
def test_every_timing_and_fault_near_it(earful):
earful.explore(booking).assert_contracts()
3. Run it.
pytest
The conversation as written passes. The search fails, in about half a minute:
test_booking.py .F [100%]
=================================== FAILURES ===================================
_____________________ test_every_timing_and_fault_near_it ______________________
earful = <earful.pytest_plugin.Earful object at 0x...>
def test_every_timing_and_fault_near_it(earful):
> earful.explore(booking).assert_contracts()
E earful.core.checker.report.ContractFailure: booking on livekit-agents 1.8.13: 736 cases tried, 736 judged, 1 contract rule(s) broken
E 809 run(s): 6 to find where to put things, 732 for the cases, 71 to measure the failures
E by contract: pass, fail, nothing to judge, evidence lost
E A1 0 0 736 0
E A2 453 272 11 0
E A3 672 0 64 0
E M1 732 0 4 0
E M2 736 0 0 0
E L1 701 0 35 0
E L2 0 0 736 0
E
E A2/rule in 272 case(s)
E 2 durable effects for 'book-table'; the scenario authorized 1
E changed: backend.timeout 1, commit first
E also by changing: backend.timeout 1, commit first + backend.latency 1; backend.timeout 1, commit first + backend.wait 1; backend.timeout 1, commit later; backend.timeout 1, commit later + backend.wait 1
E breaks with backend.latency 1 from 0.000 s (no case exists beyond it) to 6.000 s (passes beyond it)
E breaks with backend.wait 1 from 0.000 s (no case exists beyond it) to 32.768 s (still breaks where the search stopped)
test_booking.py:57: ContractFailure
------------------------------------ earful ------------------------------------
search 1 (booking) breaks A2/rule: backend.timeout 1, commit first
case .earful/test_booking.py-test_every_timing_and_fault_near_it/search-1.booking.A2-rule.case.json
ledger .earful/test_booking.py-test_every_timing_and_fault_near_it/search-1.booking.A2-rule.ledger.jsonl
report .earful/test_booking.py-test_every_timing_and_fault_near_it/search-1.booking.A2-rule.html
=========================== short test summary info ============================
FAILED test_booking.py::test_every_timing_and_fault_near_it - earful.core.che...
========================= 1 failed, 1 passed in 25.19s =========================
Earful ran the conversation 736 times, each with one time moved or one backend fault added. In 272 of them the restaurant holds two bookings. The simplest is the first one listed: the reservation service takes the booking, the agent's tool stops waiting before it hears back, the model is told the tool failed and tries again.
4. Look at it. The failure names a report. Open it in a browser:
open .earful/test_booking.py-test_every_timing_and_fault_near_it/search-1.booking.A2-rule.html
The page is a timeline of that run. On the backend lane the first write commits at 3.0 s
(a filled diamond). A second later its caller stops waiting (a clock) and the tool raises
(a cross). The model tries again, and a second write commits at 4.6 s. Under Verdicts, A2
links to the two commits it rests on. docs/report.md explains every
mark.
5. Keep it. Reduce the failure to the smallest case that still breaks the rule, and save it:
earful search test_booking:booking --keep A2/rule --out failures
earful replay failures/lk-1.8.13.booking.A2-rule --expect reproduced
The kept case is the conversation as written with one fault: the first write times out for its caller. It gives the same ledger, byte for byte, on every run.
6. Fix it. The service honours an idempotency key and the agent never sends one. In
agent.py:
confirmation = await self._reservations.create(
party_size, idempotency_key=f"table-for-{party_size}"
)
pytest # 2 passed
earful replay failures/lk-1.8.13.booking.A2-rule --expect clean # the kept failure is gone
The kept failure is now a regression test: earful replay --expect clean fails if the
double booking ever comes back.
To test your own LiveKit agent, generate a first test from its tools.
earful init myapp.agent:SupportAgent # writes test_support_agent.py
pytest test_support_agent.py
The test it writes runs as it is. Every tool is declared an effect, so no tool body runs
and nothing reaches a real service. The scripted model calls the first tool, and calls it
once more if the call fails. With no tool body run, Earful cannot see whether a write
carries an idempotency key, so the search fails on the repeated write (A2) until the file
declares the key the tool sends. The file marks that and what else to change: what the
user says, which tool the model calls, and which tools only read. docs/testing.md covers
the rest.
With a coding assistant
Earful is new, so an assistant such as Claude Code or Cursor has not seen its API and
will guess at it. skills/earful/SKILL.md is one page that tells
it how to write and read an Earful test. Copy it to where your assistant keeps its skills
or rules (.claude/skills/earful/SKILL.md for Claude Code, a file under .cursor/rules/
for Cursor), then ask for a test of your agent.
What is checked
Each contract is decided from the ledger alone (docs/contracts.md).
| Contract | It fails when | |
|---|---|---|
| A1 | Retired intent | The user cancels or corrects something and a new write for it starts anyway |
| A2 | One logical effect | One request leaves more durable effects than it was allowed |
| A3 | Truthful confirmation | The user hears that something succeeded before the backend recorded it |
| M1 | Played vs. remembered | What the agent remembers saying is not what was played |
| M2 | Turn integrity | A model call is not shown the conversation that happened |
| L1 | Progress | A turn that is owed a reply does not get one in time |
| L2 | Interruption | The agent is audible while the user holds the floor |
A verdict is pass or fail, or, when it cannot be judged, not exercised (nothing to judge)
or unobservable (evidence lost), with a code that says why. A failed contract is evidence about one run
against what the test declared. docs/contracts.md says how to decide whether it is
a defect of the framework, of the application or of the test.
What it is not
Earful does not grade conversations, prompts, recognition accuracy or voice quality. The
model, the recognizer and the voice are scripted, so it says nothing about how a real
provider behaves. Playout is what a simulated sink consumed: it does not measure a
network, a client buffer or what a caller heard. It does not record production calls.
docs/limits.md lists every limit in one place.
Two known defects, reproduced
The same search finds both, and the same contracts check them on every supported
LiveKit release. Both also break the same rules when the reduced case is run on the
real clock (earful crosscheck).
| Issue | What happens | Fails on | Passes on |
|---|---|---|---|
| livekit/agents#3702 | A tool result is lost when its reply is interrupted, and the booking is made twice | 1.5.6, 1.5.7, 1.6.5 | 1.6.6, 1.8.12, 1.8.13 |
| livekit/agents#5509 | A reply starts playing after the user has begun a new turn | 1.5.6 | 1.5.7, 1.6.5, 1.6.6, 1.8.12, 1.8.13 |
Both kept cases are in the repository, under tests/bundles/, and are not part of the
installed package. From a checkout:
earful replay tests/bundles/lk-1.5.6.book_then_interrupt.A2-rule
earful report tests/bundles/lk-1.5.6.book_then_interrupt.A2-rule -o report.html
Supported
livekit-agents 1.5.6, 1.5.7, 1.6.5, 1.6.6, 1.8.12 and 1.8.13, on Linux and macOS,
Python 3.10 to 3.14. pipecat-ai 1.16.0, on Linux and macOS, Python 3.11 to 3.13.
docs/compatibility.md has the exact dependency sets
and what CI runs for each.
Documentation
| Page | What it covers |
|---|---|
docs/testing.md |
Writing a test: the scenario, the scripted model, side effects, pytest, the command line, the real clock |
docs/pipecat.md |
Running a Pipecat scenario, registering tools and configuring turn detection |
docs/scripting.md |
Scripting the model so it behaves as a real one does: retries, replies that only call a tool, cancellations |
docs/adapters.md |
Writing an adapter for another framework |
docs/api.md |
Every public name, the earful command's options and the pytest plugin |
docs/troubleshooting.md |
The messages Earful prints, with the cause of each and what to do |
docs/report.md |
The HTML report, lane by lane |
docs/contracts.md |
The seven contracts, their evidence and their policies |
docs/search.md |
The search, the reduction of a failing case, and the bundle that is kept |
docs/ledger.md |
Every event in a ledger, and what makes a run valid |
docs/compatibility.md |
Supported releases and what is tested |
docs/limits.md |
What Earful does not do and what it cannot see |
docs/glossary.md |
The terms the pages, the command and the reports use |
CHANGELOG.md |
What changed in each release |
Layout
src/earful/core/is the portable part: ledger, validator, contract checker, effect backend, case format, search, shrinker, bundle, report. It imports no framework.src/earful/scripted/is what every adapter shares: the virtual clock, and the scripted user, model and voice. It imports no framework either.src/earful/livekit/is the LiveKit adapter: scripted providers, tool witness, clocked sink, harness.src/earful/pipecat/runs scripted providers and a clocked output transport through a Pipecat pipeline.examples/holds the quickstart and the same bot for Pipecat.tests/golden/andtests/bundles/hold the reference ledgers and the two kept failures.
Contributing
CONTRIBUTING.md covers setup, the checks and the rules the code
keeps. Apache-2.0.
Metadata
Release files for earful 0.3.0
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 |
|---|---|---|---|---|
| earful-0.3.0.tar.gz | 867.1 kB | With provenance | Details for earful-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| earful-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for earful-0.3.0-py3-none-any.whl |
Total release size: 1.1 MB
Release files / earful-0.3.0.tar.gz
| Download URL | earful-0.3.0.tar.gz |
|---|---|
| Size | 867.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
48118900751c3a45515eca6aff01c50d56fced44f0d8b1c0ee0ae616e814a1a0
|
|
BLAKE2b-256 checksum How to use checksums |
bda64ca614b0fbe932791ef6591510089aa29f5cff5edaa140b3ce0c055e17a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / earful-0.3.0-py3-none-any.whl
| Download URL | earful-0.3.0-py3-none-any.whl |
|---|---|
| Size | 250.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5b6aa2b53e1c677071f9ab6e3aa3256ba2b4b0c30a5a57ee2c2634b06fffc31
|
|
BLAKE2b-256 checksum How to use checksums |
fe201e8110eafb0df3dcc5a8e046d2bdf8208e0c02783f1178666cc33488d01a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logSecurity for earful 0.3.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for earful-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logA 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.