Documentation Index
Fetch the complete documentation index at: https://futureagi.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Testing a Voice AI Agent with Agent Simulate SDK
This notebook demonstrates how to use theagent-simulate SDK to test a conversational voice AI agent.
We will:
- Install the necessary libraries.
- Start a local LiveKit development server.
- Set up environment variables.
- Define a simple, local support agent to act as the agent-under-test.
- Define a test scenario with a simulated customer persona.
- Run the simulation and record the conversation.
- Display the transcript and play back the recorded audio.
- Run evaluations on the conversation.
1. Installation
First, let’s install theagent-simulate SDK and other required Python packages.
Download VAD Model
Thelivekit-agents SDK uses the Silero VAD (Voice Activity Detection) plugin. We need to download its model weights before we can start the simulation.
2. Start LiveKit Server
For this demo, we’ll run a local LiveKit development server. Open a new terminal and run the following commands to download and start the server:3. Set Environment Variables
We need to configure our API keys and LiveKit server details. Thelivekit-server --dev command prints the key, secret, and URL you need.
Important:
- Copy the
API Key,API Secret, andURLfrom thelivekit-serveroutput. - You will also need an
OPENAI_API_KEYfor the simulated customer’s LLM. - If you want to run evaluations, you’ll also need your
FI_API_KEYandFI_SECRET_KEY.
4. Define the Agent-Under-Test
Instead of connecting to a remote, deployed agent, we’ll define and run a simpleSupportAgent locally. The TestRunner will manage spawning this agent for each test case.
5. Define Test Scenario & Persona
Now we’ll use theagent-simulate SDK to define the test case. We need two main components:
AgentDefinition: Tells theTestRunnerhow to spawn our localSupportAgent.Scenario: Contains one or morePersonaobjects that define the simulated customer’s details.
6. Run the Simulation
Now we’ll instantiate theTestRunner and call run_test. This will:
- Create a new, unique LiveKit room for this test.
- Spawn our
SupportAgentand connect it to the room. - Connect the simulated customer (“Fubar”) to the room.
- Record the full conversation.
- Return a
TestReportcontaining the results.
7. View Results
TheTestReport object contains the full transcript and paths to the recorded audio files. Let’s display the transcript. In an interactive notebook, you could use IPython.display.Audio to play back the combined conversation.
8. Run Evaluations
Theagent-simulate SDK includes a helper function, evaluate_report, to easily run evaluations on your test results using the ai-evaluation library.
You define a list of eval_specs, which map fields from the TestReport (like transcript or audio_combined_path) to the inputs required by your chosen evaluation templates.