plain-hamburger-12701
03/25/2026, 4:21 AMtall-airline-16756
03/25/2026, 4:22 AMtall-airline-16756
03/25/2026, 4:22 AMnext_event().is_message()), assert function calls/outputs, and run LLM-based judgments (.judge(llm, intent="...")) for qualitative matching beyond exact-string equality.
• Test helpers work with realtime models in text mode, so you can validate expected behavior even if your production agent uses realtime audio models.
When to consider agent-to-agent testing
• If you want stronger, automated end-to-end conversational evaluation without human input, create an evaluation agent that plays the user role.
• Configure room input options to allow agent input and have the evaluation agent send your Q&A items and judge responses automatically.
When to use third-party tools (audio-level testing)
• If you need to validate the full audio pipeline (ASR quality, TTS output, latency, audio artifacts) use an end-to-end voice testing provider:
◦ Bluejay, Cekura, Coval, or Hamming — these services simulate real audio calls at scale and provide monitoring/metrics across many permutations.
• Use them only if audio-level fidelity and production monitoring are required; otherwise text testing covers conversational logic and intent validation.
Practical test plan to get started
1. Prepare your Q&A list in a structured format (CSV/JSON) with fields: id, user_question, expected_intent_or_response, tolerance (exact vs. semantic).
2. Implement a text-only test harness using the Agents testing helpers:
a. Create an AgentSession for the agent under test.
b. For each Q&A:
▪︎ Call await session.run(user_input="...")
▪︎ Inspect the next event: result.expect.next_event().is_message(role="assistant")
▪︎ Use .judge(llm, intent="...") for semantic checks or assert on message text for exact-match cases.
1. Run tests in CI (GitHub Actions) using secrets for any LLM API keys the judge needs.
2. Add failure metrics and reporting: pass/fail, confidence from the LLM judge, and example mismatches for debugging.
3. If you want to simulate more realistic dialogues, group Q&A items into multi-turn scenarios and validate stateful behavior.
If you want an example
• I can show a small pytest example that reads a JSON list of Q&A and runs the session + .judge(...) assertions.
• Or I can show how to build an evaluation agent that runs agent-to-agent tests inside a LiveKit Room.
Which would you like?
• A short pytest example for text-only validation (recommended first step), OR
• A sample agent-to-agent test setup to simulate interactive evaluation, OR
• Guidance on choosing/configuring a third-party audio testing provider for end-to-end audio validation
Pick one and I’ll provide the step-by-step example and code snippets.
Sources: Testing and evaluation | LiveKit Documentation | Agents (Python) | livekit/livekit_composite | DeepWiki | examples/voice_agents | livekit/livekit_composite | DeepWiki | examples/frontdesk | livekit/livekit_composite | DeepWiki | LiveKit's Series C: Towards the voice-driven era of computing | LiveKit, with interactive elementsplain-hamburger-12701
03/25/2026, 4:23 AMtall-airline-16756
03/25/2026, 4:23 AMsession.run(user_input=...).
• Uses an LLM-based judge to compare the agent response to an expected intent/response description.
• Prints pass/fail with feedback for each case.
Requirements
• Python 3.8+
• Install the required package(s) (adjust package name if your environment differs):
pip install "livekit-agents[silero]" python-dotenv
• Your agent implementation accessible locally (example assumes an Assistant class you provide).
Files 1) test_cases.json (example)
[
{
"id": "greeting-1",
"question": "Hello, how are you?",
"expected_intent": "Responds warmly and offers assistance."
},
{
"id": "weather-1",
"question": "What's the weather in Tokyo?",
"expected_intent": "Explains it cannot check live weather or asks for location details."
},
{
"id": "joke-1",
"question": "Tell me a joke.",
"expected_intent": "Tells a short, friendly joke."
}
]
2) validate_agent.py
import asyncio
import json
from pathlib import Path
# Imports from LiveKit testing helpers
from livekit.agents import AgentSession
from livekit.plugins import inference
# Replace with your actual agent class/module
# Example: from my_agent import Assistant
from your_agent_module import Assistant
TEST_FILE = Path("test_cases.json")
async def run_validation():
# Use an LLM for judgment (can be any supported LLM)
llm = inference.LLM(model="openai/gpt-4o-mini") # adjust model/provider as needed
# Load test cases
cases = json.loads(TEST_FILE.read_text())
# Start a session and the local agent
async with AgentSession(llm=llm) as session:
await session.start(Assistant()) # assumes Assistant is your Agent subclass
all_passed = True
for case in cases:
qid = case.get("id", "<no-id>")
question = case["question"]
expected = case.get("expected_intent", "")
print(f"\n🔍 Test {qid}: '{question}'")
# Send text-only user input
result = await session.run(user_input=question)
# Inspect next event for an assistant message and ask the LLM judge to evaluate it
judged = await result.expect.next_event().is_message(role="assistant").judge(
llm, intent=expected
)
if judged.passed:
print(f"✅ Passed: {judged.feedback}")
else:
all_passed = False
reason = getattr(judged, "reason", "No reason provided")
print(f"❌ Failed: {reason}")
print(f" Judge feedback: {getattr(judged, 'feedback', '')}")
if all_passed:
print("\n🎉 All tests passed.")
else:
print("\n⚠️ Some tests failed. See output above for details.")
if __name__ == "__main__":
asyncio.run(run_validation())
How to adapt this to your environment
• Replace from your_agent_module import Assistant with your agent class. The Assistant should be the agent you run locally (subclass of Agent).
• Change the judge LLM model string if you use another provider or model.
• For strict matching instead of LLM judgment, replace the .judge(...) call with a direct text check:
msg = await result.expect.next_event().is_message(role="assistant").get_text()
if expected_exact == msg.strip():
passed = True
• To run multi-turn scenarios, send subsequent session.run(user_input=...) calls in sequence and assert on the sequence of events.
CI tips
• Use secrets for any LLM API keys.
• Run this script in CI to validate regressions on each push.
• Collect judge feedback and failure examples for debugging.
If you want, I can:
• Provide a pytest-style test wrapper for CI integration.
• Convert this to a Node.js example.
• Show a CSV-driven loader instead of JSON.
Which would you like next?
Sources: Testing and evaluation | LiveKit Documentation, with interactive elementsplain-hamburger-12701
03/25/2026, 4:26 AMtall-airline-16756
03/25/2026, 4:26 AM