{
 "schema_version": 1,
 "generated": "2026-11-09",
 "id": "livekit-agents--write-unit-tests-for-a-livekit-voice-agent",
 "repo": "livekit/agents",
 "repo_url": "https://github.com/livekit/agents",
 "repo_slug": "livekit-agents",
 "title": "Write tests for your agent's behavior",
 "page_title": "How to write tests for your agent's behavior with Agents",
 "summary": "Use AgentSession in pytest to check that the agent calls the right tool for a user message.",
 "who": "A team shipping a voice agent that must behave predictably.",
 "problem": "Voice Agents change behavior silently when prompts or models change.",
 "outcome": "Pytest tests that fail when the agent stops calling the expected tool.",
 "steps": [
  "Install pytest and your agent's dependencies",
  "Write an async test that starts AgentSession with your agent, as in the README",
  "Send a user_input with sess.run and assert the expected function call",
  "Run the suite with `uv run pytest --unit` in the repo, or pytest in your project"
 ],
 "agent_prompt": "Using livekit/agents, write a pytest test like the README's test_no_availability that checks my agent calls <my tool> when the user says <phrase>, and run it.",
 "agents": [
  "claude-code",
  "codex",
  "cursor",
  "gemini-cli"
 ],
 "difficulty": "Advanced",
 "time": "1 hour",
 "basis": "readme",
 "caveat": "Tests that use a real LLM call the provider and can be slow or flaky.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "python",
 "requirements": [
  "Python with pip",
  "A LiveKit server or LiveKit Cloud project",
  "API keys for the model providers you choose"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/livekit-agents/write-unit-tests-for-a-livekit-voice-agent/",
 "md": "https://dedupedai.com/use-cases/livekit-agents/write-unit-tests-for-a-livekit-voice-agent/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/livekit-agents--write-unit-tests-for-a-livekit-voice-agent.json",
 "api_version": "v1"
}
