AutoVoiceEvals

repository·main·Indexed 41 days ago

https://github.com/archishmansengupta/autovoiceevals

A self-improving loop for voice AI agents that uses adversarial testing to iteratively optimize system prompts. It automates generating attacks, testing improvements, and scoring performance across providers including Vapi, Smallest AI, ElevenLabs ConvAI, and LiveKit. Features include a 'research' mode for continuous optimization and a 'pipeline' mode for single-pass audits.

Tokens
2.5K
Snippets
9
Records
16
Agent score
98%

What's inside AutoVoiceEvals

  1. Project structure and core components

    main

    The repository is organized as follows:

    • main.py: The primary entry point.
    • config.yaml: The main configuration file for users to edit.
    • .env.example: A template for API keys; copy this to .env.
    • examples/: Contains provider-specific configuration templates (vapi.config.yaml, smallest.config.yaml, elevenlabs.config.yaml, livekit.config.yaml).
    • autovoiceevals/: The core package containing the CLI, config loaders, provider clients (Vapi, Smallest, ElevenLabs, LiveKit), the Claude LLM client, the evaluator, and the research/pipeline logic.
  2. Use ElevenLabs `simulate-conversation` with dynamic variables

    main
    When using the ElevenLabs ConvAI provider, the simulate-conversation endpoint runs the entire conversation in one call by providing an adversarial user persona. If your agent's tools require runtime variables (for example, Twilio's system__caller_id), you must pass them via assistant.dynamic_variables in your config.yaml.
  3. Compare supported voice agent providers

    main

    The project supports four different providers for evaluating voice agents, each with different conversation mechanisms and prompt management styles:

    • Vapi: Uses live multi-turn conversations via the Vapi Chat API. Prompts are managed via the assistant PATCH endpoint.
    • Smallest AI: Uses simulated conversations where Claude plays the agent using the system prompt from the platform. This is used because Atoms agents only accept audio via LiveKit and lack a text chat API. Prompts are managed via the Atoms workflow API.
    • ElevenLabs ConvAI: Uses the native simulate-conversation endpoint. ElevenLabs runs the real deployed agent (including tools and knowledge base) and plays the user via a persona prompt. This is a single API call that is highly realistic. Prompts are managed via the agent PATCH endpoint.
    • LiveKit: Uses text-based evaluations via LiveKit data channel messages (Phase 1, no audio). The caller bot joins a room and exchanges JSON turns. Prompt management is delegated to an agent_backend (e.g., "smallest") or managed externally.
  4. Understand the scoring mechanism

    main

    Each evaluation scenario produces a composite score calculated as follows:

    composite = 0.50 * should_score + 0.35 * should_not_score + 0.15 * latency_score

    • should_score: The fraction of "agent should do X" criteria passed.
    • should_not_score: The fraction of "agent should NOT do X" criteria passed.
    • latency_score: 1.0 if the response is under 3 seconds, otherwise 0.5.

    Weights and thresholds for these components are configurable in config.yaml under the scoring: key.

    Note on Simplicity: If a prompt change results in the same score but a shorter prompt length, the system treats it as a KEEP to favor efficiency and lower costs.

  5. How to write an effective agent description

    main

    The description field is critical because Claude uses it to generate adversarial attacks. Instead of writing attack vectors manually, you provide context so the system can figure out how to break your agent.

    To maximize attack quality, include:

    • Core Functionality: What the agent does (e.g., booking, support).
    • Offerings: Services, menu items, or products with specific prices.
    • Contextual Details: Staff names, roles, business hours, and locations.
    • Policies: Cancellation rules, refund policies, or delivery zones.
    • Constraints: Explicitly state what the agent cannot do (e.g., 'cannot give medical advice', 'cannot override pricing').
  6. Configure API keys in .env

    main

    Create a .env file by copying the example and populate it with your API keys. You must provide an ANTHROPIC_API_KEY (used by Claude to generate scenarios and judge conversations) and the key for your specific voice platform.

    Required Keys:

    • ANTHROPIC_API_KEY (Always required)

    Platform-Specific Keys:

    • Vapi: VAPI_API_KEY
    • Smallest AI: SMALLEST_API_KEY
    • ElevenLabs: ELEVENLABS_API_KEY
    • LiveKit: LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET
    cp .env.example .env
  7. Run autovoiceevals in research or pipeline mode

    main

    The project provides two primary execution modes via the CLI:

    • Research Mode (python main.py research): An autoresearch loop designed for iterative prompt optimization. It proposes one change at a time, keeps changes that improve the score, and reverts those that do not. It runs until max_experiments is reached.
    • Pipeline Mode (python main.py pipeline): A single-pass audit. It generates adversarial attacks, performs a one-shot prompt improvement, and then verifies the result. This is best for a quick assessment of agent weaknesses.
    # For iterative prompt optimization
    python main.py research
    
    # For a quick single-pass audit
    python main.py pipeline
  8. Configure your agent in config.yaml

    main

    Initialize your configuration by copying the template corresponding to your provider. You must then edit config.yaml to include your agent's id and a detailed description.

    Setup commands:

    # For Vapi
    cp examples/vapi.config.yaml config.yaml
    
    # For Smallest AI
    cp examples/smallest.config.yaml config.yaml
    
    # For ElevenLabs
    cp examples/elevenlabs.config.yaml config.yaml
    
    # For LiveKit
    cp examples/livekit.config.yaml config.yaml

    Required Configuration Fields:

    • provider: One of vapi, smallest, elevenlabs, or livekit.
    • assistant.id: The unique ID of your agent from your platform's dashboard.
    • assistant.description: A detailed text description of your agent's capabilities, rules, and constraints (see 'Writing a good description' for details).
    provider: vapi
    
    assistant:
      id: "your-agent-id"
      description: |
        Your agent description goes here...
  9. Review research results and logs

    main

    After a run, detailed data is stored in the results/ directory:

    | File | Description | |---|---|results.tsv| One row per experiment containing score, CSAT, and pass rate.| | results/autoresearch.json| Full dataset including transcripts, eval criteria, proposals, and reasoning.| | results/best_prompt.txt| The highest-scoring prompt found during the run, ready for deployment.|

    You can also view a human-readable summary via the CLI: python main.py results.

  10. Run autovoiceevals research and pipeline modes

    main

    Use the main.py CLI to execute different optimization and auditing workflows.

    Commands:

    • python main.py research: Starts the iterative optimization loop. It runs until interrupted (Ctrl+C) or until autoresearch.max_experiments is reached in config.yaml. It proposes changes, tests them, and keeps improvements.
    • python main.py research --resume: Resumes a previously interrupted research run.
    • python main.py pipeline: Performs a single-pass audit (Attack $\rightarrow$ Improve $\rightarrow$ Verify) and then stops.
    • python main.py results: Displays a summary of the completed run, including score progression, experiments, and the best prompt found.
    # Iterative optimization
    python main.py research
    
    # Single-pass audit
    python main.py pipeline
    
    # View results
    python main.py results