# AI use cases for Agents (livekit/agents)

Repo: [livekit/agents](https://github.com/livekit/agents) | Use cases: 3 | Page: https://dedupedai.com/use-cases/livekit-agents/

LiveKit Agents is a Python framework for building realtime, programmable voice and multimodal agents that run on servers, with plugins for speech to text, LLMs, text to speech and realtime APIs, built in job dispatch and a test harness.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Build a voice agent and talk to it in the terminal: https://dedupedai.com/use-cases/livekit-agents/build-a-voice-agent-and-test-it-in-the-terminal-with-livekit/
- Give your voice agent a tool it can call: https://dedupedai.com/use-cases/livekit-agents/give-a-livekit-voice-agent-a-function-tool/
- Write tests for your agent's behavior: https://dedupedai.com/use-cases/livekit-agents/write-unit-tests-for-a-livekit-voice-agent/

## How to build a voice agent and talk to it in the terminal with Agents

Repo: [livekit/agents](https://github.com/livekit/agents) | Difficulty: Intermediate | Time: 45 minutes | Basis: From the README

Install livekit-agents with OpenAI, Deepgram and Cartesia plugins and run your agent in console mode.

**Who it is for:** A developer prototyping a voice assistant.

**The problem:** Testing a voice agent usually needs a full client app.

**The outcome:** A voice agent you can talk to from your terminal before connecting any client.

### Steps

1. Install with `pip install "livekit-agents[openai,deepgram,cartesia]"`
2. Write myagent.py with an Agent and AgentSession as in the README example
3. Run it locally with `python myagent.py console`
4. Switch to `python myagent.py dev` to connect it to LiveKit

### Prompt to paste into your agent

```text
Using livekit/agents, install `pip install "livekit-agents[openai,deepgram,cartesia]"`, write myagent.py based on the README weather tool example for <my use case>, and run `python myagent.py console`.
```

### Caveat

Dev and start modes need a LiveKit server or LiveKit Cloud project.

Risk, cost: Model providers bill per use.

Risk, privacy: Speech is sent to the providers you configure.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/livekit-agents/build-a-voice-agent-and-test-it-in-the-terminal-with-livekit/

## How to give your voice agent a tool it can call with Agents

Repo: [livekit/agents](https://github.com/livekit/agents) | Difficulty: Intermediate | Time: 45 minutes | Basis: From the README

Use the function_tool decorator so the agent can look up data, like the README's weather example.

**Who it is for:** A developer whose agent must fetch live data during a call.

**The problem:** A voice agent without tools can only chat, not act.

**The outcome:** An agent that calls your Python function when the user asks for it.

### Steps

1. Install with `pip install "livekit-agents[openai,deepgram,cartesia]"`
2. Define an async function with the @function_tool decorator
3. Pass it to your Agent as in the README example
4. Run `python myagent.py console` and ask a question that needs the tool

### Prompt to paste into your agent

```text
With livekit/agents, add a @function_tool to my agent that looks up <my data source>, register it on the Agent, and test it with `python myagent.py console`.
```

### Caveat

Tool results are read aloud by the agent, so keep them short.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/livekit-agents/give-a-livekit-voice-agent-a-function-tool/

## How to write tests for your agent's behavior with Agents

Repo: [livekit/agents](https://github.com/livekit/agents) | Difficulty: Advanced | Time: 1 hour | Basis: From the README

Use AgentSession in pytest to check that the agent calls the right tool for a user message.

**Who it is for:** A team shipping a voice agent that must behave predictably.

**The problem:** Voice Agents change behavior silently when prompts or models change.

**The outcome:** Pytest tests that fail when the agent stops calling the expected tool.

### Steps

1. Install pytest and your agent's dependencies
2. Write an async test that starts AgentSession with your agent, as in the README
3. Send a user_input with sess.run and assert the expected function call
4. Run the suite with `uv run pytest --unit` in the repo, or pytest in your project

### Prompt to paste into your agent

```text
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.
```

### Caveat

Tests that use a real LLM call the provider and can be slow or flaky.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/livekit-agents/write-unit-tests-for-a-livekit-voice-agent/
