Claude Cursor Skill

livekit-skills

Build voice AI agents with LiveKit Agents SDK. Use when the user asks to "build a voice agent", "create a LiveKit agent", "add voice AI", "implement handoffs", "structure agent workflows", or is working with LiveKit Agents SDK. Covers both LiveKit Cloud and self-hosted deployment

LLM Mart · 0 points · 8 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download fcakyon-claude-codex-settings-plugins_livekit-skills_skills_livekit-skills-4632eb3.zip · 15 KB
Part of fcakyon/claude-codex-settings — 83 skills

Install

skills CLI npx skills add https://github.com/fcakyon/claude-codex-settings/tree/main/plugins/livekit-skills/skills/livekit-skills
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install fcakyon-claude-codex-settings@llmmart
Git git clone https://github.com/fcakyon/claude-codex-settings.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole fcakyon/claude-codex-settings collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

LiveKit Voice Agent Development

This skill provides guidance for building voice AI agents with the LiveKit Agents SDK. It covers both LiveKit Cloud and self-hosted deployments, using the lk CLI for documentation access and project management. All factual information about APIs, methods, and configurations must come from live documentation.

MANDATORY: Read This Checklist Before Starting

Before writing ANY code, complete this checklist:

  1. Read this entire skill document - Do not skip sections
  2. Set up LiveKit credentials (Cloud project or self-hosted server) - You need LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET
  3. Set up documentation access - Install lk CLI for lk docs commands
  4. Plan to write tests - Every agent implementation MUST include tests (see testing section below)
  5. Verify all APIs against live docs - Never rely on model memory for LiveKit APIs

Setup

LiveKit Cloud

LiveKit Cloud is the fastest way to get a voice agent running. It provides:

  • Managed infrastructure (no servers to deploy)
  • LiveKit Inference for AI models (no separate API keys needed)
  • Built-in noise cancellation, turn detection, and other voice features
  • Simple credential management

Connect to Your Cloud Project

  1. Sign up at cloud.livekit.io if you haven't already

  2. Create a project (or use an existing one)

  3. Get your credentials from the project settings:

    • LIVEKIT_URL - Your project's WebSocket URL (e.g., wss://your-project.livekit.cloud)
    • LIVEKIT_API_KEY - API key for authentication
    • LIVEKIT_API_SECRET - API secret for authentication
  4. Set these as environment variables (typically in .env.local):

LIVEKIT_URL=wss://your-project.livekit.cloud
LIVEKIT_API_KEY=your-api-key
LIVEKIT_API_SECRET=your-api-secret

The LiveKit CLI can automate credential setup. Consult the CLI documentation for current commands.

Use LiveKit Inference for AI Models

LiveKit Inference is one option for AI model access when using LiveKit Cloud. It provides access to leading AI model providers—all through your LiveKit credentials with no separate API keys needed.

Benefits of LiveKit Inference:

  • No separate API keys to manage for each AI provider
  • Billing consolidated through your LiveKit Cloud account
  • Optimized for voice AI workloads

Consult the documentation for available models, supported providers, and current usage patterns. The documentation always has the most up-to-date information.

Self-Hosted Setup

Self-hosting removes Cloud tier limits on deployments and concurrency. You control scaling directly.

Local development

Install and run the LiveKit server:

  • macOS: brew install livekit
  • Linux: curl -sSL https://get.livekit.io | bash

Start in dev mode:

livekit-server --dev

Default credentials: API key devkey, API secret secret.

Set environment variables:

LIVEKIT_URL=ws://localhost:7880
LIVEKIT_API_KEY=devkey
LIVEKIT_API_SECRET=secret

Production deployment

Deploy livekit-server via Docker, Kubernetes, or VMs on any provider (Hetzner, AWS, GCP, etc.). Consult lk docs get-page /home/self-hosting or see references/self-hosting.md for details. Agent servers run as regular processes managed by your infra tooling.

Using Your Own Model Providers

When self-hosting or when you prefer your own API keys over LiveKit Inference, configure model providers directly via environment variables:

# STT (Speech-to-Text)
DEEPGRAM_API_KEY=your-key

# LLM
OPENAI_API_KEY=your-key

# TTS (Text-to-Speech)
ELEVEN_API_KEY=your-key
# or
CARTESIA_API_KEY=your-key

The Agents SDK has plugins for all major providers. Pass model identifiers directly:

Node.js / TypeScript:

import { voice } from "@livekit/agents";

const session = new voice.AgentSession({
  stt: "deepgram/nova-3:multi",
  llm: "openai/gpt-4.1-mini",
  tts: "cartesia/sonic-3:voice-id",  // or "elevenlabs/..."
});

Python:

session = AgentSession(
    stt="deepgram/nova-3",
    llm="openai/gpt-4.1-mini",
    tts="elevenlabs/...",  # or "cartesia/sonic-3:voice-id"
)

Consult lk docs search "plugins" for the full list of supported providers.

Project Templates

Initialize a new agent project with the CLI:

Backend agents:

lk agent init my-agent --template agent-starter-python
lk agent init my-agent --template agent-starter-node

Frontend apps (React/Next.js, React Native, Swift, Flutter, Android):

lk agent init my-frontend --template agent-starter-react
lk agent init my-frontend --template agent-starter-react-native

Omit --template to see all available templates interactively.

Critical Rule: Never Trust Model Memory for LiveKit APIs

LiveKit Agents is a fast-evolving SDK. Model training data is outdated the moment it's created. When working with LiveKit:

  • Never assume API signatures, method names, or configuration options from memory
  • Never guess SDK behavior or default values
  • Always verify against live documentation before writing code
  • Always cite the documentation source when implementing features

This rule applies even when confident about an API. Verify anyway.

Use LiveKit CLI for Documentation

Before writing any LiveKit code, use the lk docs CLI commands for current, verified API information. This prevents reliance on stale model knowledge.

Search documentation

lk docs search "voice agent quickstart"
lk docs search "handoffs and tasks"

Fetch specific pages

lk docs get-page /agents/start/voice-ai-quickstart
lk docs get-page /agents/build/tools /agents/build/vision

Search SDK source code

lk docs code-search "class AgentSession" --repo livekit/agents
lk docs code-search "@function_tool" --language Python --full-file

Check changelogs

lk docs changelog livekit/agents
lk docs changelog pypi:livekit-agents --releases 5
lk docs changelog npm:livekit-agents --releases 5

If CLI is not installed

Install the LiveKit CLI first:

  • macOS: brew install livekit-cli
  • Linux: curl -sSL https://get.livekit.io/cli | bash
  • Windows: winget install LiveKit.LiveKitCLI

As a fallback, reference pages are available in the references/ directory alongside this skill.

Voice Agent Architecture Principles

Voice AI agents have fundamentally different requirements than text-based agents or traditional software. Internalize these principles:

Latency Is Critical

Voice conversations are real-time. Users expect responses within hundreds of milliseconds, not seconds. Every architectural decision should consider latency impact:

  • Minimize LLM context size to reduce inference time
  • Avoid unnecessary tool calls during active conversation
  • Prefer streaming responses over batch responses
  • Design for the unhappy path (network delays, API timeouts)

Context Bloat Kills Performance

Large system prompts and extensive tool lists directly increase latency. A voice agent with 50 tools and a 10,000-token system prompt will feel sluggish regardless of model speed.

Design agents with minimal viable context:

  • Include only tools relevant to the current conversation phase
  • Keep system prompts focused and concise
  • Remove tools and context that aren't actively needed

Users Don't Read, They Listen

Voice interface constraints differ from text:

  • Long responses frustrate users—keep outputs concise
  • Users cannot scroll back—ensure clarity on first delivery
  • Interruptions are normal—design for graceful handling
  • Silence feels broken—acknowledge processing when needed

Workflow Architecture: Handoffs and Tasks

Complex voice agents should not be monolithic. LiveKit Agents supports structured workflows that maintain low latency while handling sophisticated use cases.

The Problem with Monolithic Agents

A single agent handling an entire conversation flow accumulates:

  • Tools for every possible action (bloated tool list)
  • Instructions for every conversation phase (bloated context)
  • State management for all scenarios (complexity)

This creates latency and reduces reliability.

Handoffs: Agent-to-Agent Transitions

Handoffs allow one agent to transfer control to another. Use handoffs to:

  • Separate distinct conversation phases (greeting → intake → resolution)
  • Isolate specialized capabilities (general support → billing specialist)
  • Manage context boundaries (each agent has only what it needs)

Design handoffs around natural conversation boundaries where context can be summarized rather than transferred wholesale.

Tasks: Scoped Operations

Tasks are tightly-scoped prompts designed to achieve a specific outcome. Use tasks for:

  • Discrete operations that don't require full agent capabilities
  • Situations where a focused prompt outperforms a general-purpose agent
  • Reducing context when only a specific capability is needed

Consult the documentation for implementation details on handoffs and tasks.

REQUIRED: Write Tests for Agent Behavior

Voice agent behavior is code. Every agent implementation MUST include tests. Shipping an agent without tests is shipping untested code.

Mandatory Testing Workflow

When building or modifying a LiveKit agent:

  1. Create a tests/ directory if one doesn't exist
  2. Write at least one test before considering the implementation complete
  3. Test the core behavior the user requested
  4. Run the tests to verify they pass

Test-Driven Development Process

When modifying agent behavior—instructions, tool descriptions, workflows—begin by writing tests for the desired behavior:

  1. Define what the agent should do in specific scenarios
  2. Write test cases that verify this behavior
  3. Implement the feature
  4. Iterate until tests pass

This approach prevents shipping agents that "seem to work" but fail in production.

What Every Agent Test Should Cover

At minimum, write tests for:

  • Basic conversation flow: Agent responds appropriately to a greeting
  • Tool invocation (if tools exist): Tools are called with correct parameters
  • Error handling: Agent handles unexpected input gracefully

Focus tests on:

  • Tool invocation: Does the agent call the right tools with correct parameters?
  • Response quality: Does the agent produce appropriate responses for given inputs?
  • Workflow transitions: Do handoffs and tasks trigger correctly?
  • Edge cases: How does the agent handle unexpected input, interruptions, silence?

Test Implementation Pattern

Use LiveKit's testing framework. Consult the testing documentation via lk docs for current patterns:

search: "livekit agents testing"

The framework supports:

  • Simulated user input
  • Verification of agent responses
  • Tool call assertions
  • Workflow transition testing

Why This Is Non-Negotiable

Agents that "seem to work" in manual testing frequently fail in production:

  • Prompt changes silently break behavior
  • Tool descriptions affect when tools are called
  • Model updates change response patterns

Tests catch these issues before users do.

Skipping Tests

If a user explicitly requests no tests, proceed without them but inform them:

"I've built the agent without tests as requested. I strongly recommend adding tests before deploying to production. Voice agents are difficult to verify manually and tests prevent silent regressions."

Common Mistakes to Avoid

Overloading the Initial Agent

Starting with one agent that "does everything" and adding tools/instructions over time. Instead, design workflow structure upfront, even if initial implementation is simple.

Ignoring Latency Until It's a Problem

Latency issues compound. An agent that feels "a bit slow" in development becomes unusable in production with real network conditions. Measure and optimize latency continuously.

Copying Examples Without Understanding

Examples in documentation demonstrate specific patterns. Copying code without understanding its purpose leads to bloated, poorly-structured agents. Understand what each component does before including it.

Skipping Tests Because "It's Just Prompts"

Agent behavior is code. Prompt changes affect behavior as much as code changes. Test agent behavior with the same rigor as traditional software. Never deliver an agent implementation without at least one test file.

Assuming Model Knowledge Is Current

Reiterating the critical rule: never trust model memory for LiveKit APIs. The SDK evolves faster than model training cycles. Verify everything.

When to Consult Documentation

Always consult documentation for:

  • API method signatures and parameters
  • Configuration options and their valid values
  • SDK version-specific features or changes
  • Deployment and infrastructure setup
  • Model provider integration details
  • CLI commands and flags

This skill provides guidance on:

  • Architectural approach and design principles
  • Workflow structure decisions
  • Testing strategy
  • Common pitfalls to avoid

The distinction matters: this skill tells you how to think about building voice agents. The documentation tells you how to implement specific features.

Feedback Loop

When using LiveKit documentation via lk docs, note any gaps, outdated information, or confusing content. Reporting documentation issues helps improve the ecosystem for all developers.

Summary

Building effective voice agents with LiveKit Cloud requires:

  1. Use LiveKit Cloud + LiveKit Inference as the foundation—it's the fastest path to production
  2. Verify everything against live documentation—never trust model memory
  3. Minimize latency at every architectural decision point
  4. Structure workflows using handoffs and tasks to manage complexity
  5. Test behavior before and after changes—never ship without tests
  6. Keep context minimal—only include what's needed for the current phase

These principles remain valid regardless of SDK version or API changes. For all implementation specifics, consult the LiveKit documentation via lk docs.

Files (claude-codex-settings)
  • references
    • agent-tools.md 5.4 KB
      ## /agents/build/tools
      
      LiveKit docs › Build Agents › Logic & Structure › Tool definition & use › Overview
      
      ---
      
      # Tool definition and use
      
      > Let your agents call external tools and more.
      
      ## Overview
      
      LiveKit Agents has full support for LLM tool use. This feature allows you to create a custom library of tools to extend your agent's context, create interactive experiences, and overcome LLM limitations. Tools can run synchronously or [in the background](https://docs.livekit.io/agents/logic/tools/async.md), letting the agent keep talking while long-running work completes.
      
      Within a tool, you can:
      
      - Generate [agent speech](https://docs.livekit.io/agents/build/audio.md) with `session.say()` or `session.generate_reply()`.
      - Call methods on the frontend using [RPC](https://docs.livekit.io/transport/data/rpc.md).
      - Handoff control to another agent as part of a [workflow](https://docs.livekit.io/agents/logic/workflows.md).
      - Store and retrieve session data from the `context`.
      - Anything else that a Python function can do.
      - [Call external APIs or lookup data for RAG](https://docs.livekit.io/agents/build/external-data.md).
      
      ### Tool types
      
      Two types of tools are supported:
      
      - **Function tools**: Tools that are defined as functions within your agent's code base and can be called by the LLM.
      - **Provider tools**: Tools provided by a specific model provider (e.g. OpenAI, Gemini, etc.) and are executed internally by the provider's model server.
      
      ### Provider tools
      
      Available in:
      - [x] Node.js
      - [x] Python
      
      Many LLM providers, including OpenAI, Gemini, and SpaceXAI, include built-in server-side tools that are executed entirely within a single API call. Examples include web search, code execution, and file search. These tools, called "provider tools" in LiveKit Agents, can be added to any agent that uses a supported LLM. Where the underlying provider supports it, you can mix provider tools with function tools by passing them to the `tools` parameter on your `Agent`.
      
      Node.js provider tools are currently available for OpenAI and Gemini.
      
      **Python**:
      
      ```python
      from livekit.plugins import openai  # replace with any supported provider
      
      agent = MyAgent(
          llm=openai.responses.LLM(model="gpt-4.1"),
          tools=[openai.tools.WebSearch()],  # replace with any supported tool
      )
      
      ```
      
      ---
      
      **Node.js**:
      
      ```typescript
      import { voice } from '@livekit/agents';
      import * as openai from '@livekit/agents-plugin-openai';
      
      const agent = voice.Agent.create({
        instructions: 'You are a helpful assistant.',
        llm: new openai.responses.LLM({ model: 'gpt-4.1' }),
        tools: [new openai.WebSearch()],
      });
      
      ```
      
      Refer to the documentation for each model provider for usage details.
      
      | Provider | Supported tools |
      | [Anthropic](https://docs.livekit.io/agents/models/llm/anthropic.md#provider-tools) | `ComputerUse` |
      | [Gemini](https://docs.livekit.io/agents/models/llm/gemini.md#provider-tools) | `GoogleSearch`, `GoogleMaps`, `URLContext`, `FileSearch`, `ToolCodeExecution` |
      | [Mistral AI](https://docs.livekit.io/agents/models/llm/mistralai.md#provider-tools) | `WebSearch`, `DocumentLibrary`, `CodeInterpreter` |
      | [OpenAI](https://docs.livekit.io/agents/models/llm/openai.md#provider-tools) | `WebSearch`, `FileSearch`, `CodeInterpreter` |
      | [SpaceXAI](https://docs.livekit.io/agents/models/llm/spacexai.md#provider-tools) | `WebSearch`, `XSearch`, `FileSearch` |
      
      ### Examples
      
      The following additional examples show how to use tools in different ways:
      
      - **[Dynamic tool creation](https://docs.livekit.io/agents/logic/tools/definition.md#adding-tools-dynamically)**: Set the tools list directly and share tools between agents.
      
      - **[MCP Agent](https://docs.livekit.io/reference/recipes/http_mcp_client.md)**: A voice AI agent with an integrated Model Context Protocol (MCP) client for the LiveKit API.
      
      ## In this section
      
      Read more about each topic.
      
      | Topic | Description |
      | [Function tools](https://docs.livekit.io/agents/logic/tools/definition.md) | Define function tools with decorators, RunContext, speech in tools, interruptions, dynamic tools, and error handling. |
      | [Toolsets](https://docs.livekit.io/agents/logic/tools/toolsets.md) | Group related tools and add or remove them as a unit. |
      | [Async tools](https://docs.livekit.io/agents/logic/tools/async.md) | Run long-running tools in the background so the agent can keep talking. |
      | [Model Context Protocol (MCP)](https://docs.livekit.io/agents/logic/tools/mcp.md) | Expose tools from MCP servers to your agent (Python only). |
      | [Forwarding to the frontend](https://docs.livekit.io/agents/logic/tools/forwarding.md) | Fulfill tool calls via RPC from the client. |
      
      ## Additional resources
      
      The following articles provide more information about the topics discussed in this guide:
      
      - **[RPC](https://docs.livekit.io/transport/data/rpc.md)**: Complete documentation on function calling between LiveKit participants.
      
      - **[Agent speech](https://docs.livekit.io/agents/build/audio.md)**: More information about precise control over agent speech output.
      
      - **[Workflows](https://docs.livekit.io/agents/logic/workflows.md)**: Read more about handing off control to other agents.
      
      - **[External data and RAG](https://docs.livekit.io/agents/build/external-data.md)**: Best practices for adding context and taking external actions.
      
      ---
      
      For the latest version of this document, see [https://docs.livekit.io/agents/logic/tools.md](https://docs.livekit.io/agents/logic/tools.md).
      
      To explore all LiveKit documentation, see [llms.txt](https://docs.livekit.io/llms.txt).
      
    • cli-reference.md 2.7 KB
      ## /home/cli
      
      LiveKit docs › Introduction › Understanding LiveKit › LiveKit CLI
      
      ---
      
      # LiveKit CLI
      
      > Manage your LiveKit Cloud projects and agents from the terminal
      
      ## Overview
      
      The LiveKit CLI (`lk`) is the primary tool for working with LiveKit from the terminal. Use it to manage LiveKit Cloud projects, create apps from templates, and deploy and manage agents. The CLI integrates with LiveKit Cloud for authentication and project management, and also works with self-hosted LiveKit servers for local development.
      
      - **[GitHub repository](https://github.com/livekit/livekit-cli)**: Source code and releases for the LiveKit CLI.
      
      ## Get started
      
      To install the CLI, authenticate with LiveKit Cloud, and set up your first project, see the [CLI setup guide](https://docs.livekit.io/reference/developer-tools/livekit-cli.md#setup).
      
      ## Key workflows
      
      A typical workflow starts with setting up a project, scaffolding an app from a template, and then deploying your agent to LiveKit Cloud.
      
      ### Project management
      
      Add, list, and switch between LiveKit projects. Set a default project for all other commands. For LiveKit Cloud projects, authenticate with `lk cloud auth` to link your account and import projects.
      
      - **[Project management reference](https://docs.livekit.io/reference/developer-tools/livekit-cli/projects.md)**: Learn how to add, list, and manage CLI projects.
      
      ### App templates
      
      Scaffold new applications from first-party templates. Initialize agent projects, frontends, and token servers with your project credentials already configured.
      
      - **[App templates reference](https://docs.livekit.io/reference/developer-tools/livekit-cli.md#app-templates)**: Browse available templates and learn how to create apps.
      
      ### Agent management
      
      Create, deploy, update, and monitor agents on LiveKit Cloud. Manage secrets, view logs, roll back versions, and check agent status.
      
      - **[Agent commands reference](https://docs.livekit.io/reference/developer-tools/livekit-cli/agent.md)**: Learn how to deploy and manage agents with the CLI.
      
      ### Docs search
      
      Search and browse the LiveKit documentation directly from your terminal. Fetch pages, search SDK source code, and check changelogs — useful for quick lookups and for giving [coding agents](https://docs.livekit.io/intro/coding-agents.md) direct access to up-to-date LiveKit references.
      
      - **[Docs search reference](https://docs.livekit.io/reference/developer-tools/livekit-cli/docs.md)**: Full command reference for `lk docs`.
      
      ---
      
      For the latest version of this document, see [https://docs.livekit.io/intro/basics/cli.md](https://docs.livekit.io/intro/basics/cli.md).
      
      To explore all LiveKit documentation, see [llms.txt](https://docs.livekit.io/llms.txt).
      
    • quickstart.md 16.9 KB
      ## /agents/start/voice-ai-quickstart
      
      LiveKit docs › Build Agents › Get Started › Voice AI quickstart
      
      ---
      
      # Voice AI quickstart
      
      > Build and deploy a simple voice assistant in less than 10 minutes.
      
      ## Overview
      
      This guide walks you through the setup of your very first voice assistant using LiveKit Agents. In less than 10 minutes, you'll have a voice assistant that you can speak to in your terminal, browser, telephone, or native app.
      
      > 💡 **LiveKit Agent Builder**
      > 
      > The LiveKit Agent Builder is a quick way to get started with voice agents in your browser, without writing any code. It's perfect for prototyping and exploring ideas, but doesn't have as many features as the full LiveKit Agents SDK. See the [Agent Builder](https://docs.livekit.io/agents/start/builder.md) guide for more details.
      
      ### Coding agent support
      
      LiveKit is built for coding agents like [Claude Code](https://claude.com/product/claude-code), [Cursor](https://www.cursor.com/), and [Codex](https://openai.com/codex/). These agents can build agents and frontends with the LiveKit SDKs and manage resources with the LiveKit CLI. Give your agent LiveKit expertise using the LiveKit CLI or Docs MCP server. For more information, see the [coding agents guide](https://docs.livekit.io/intro/coding-agents.md).
      
      ## Starter projects
      
      The simplest way to get your first agent running is with one of the following starter projects. You can create a project from a template with the CLI (see [Quick start with CLI](#setup-with-cli)) or click "Use this template" on GitHub and follow the project's README.
      
      These projects are constructed with best practices, a complete working agent, tests, and an AGENTS.md optimized to turn coding agents like [Claude Code](https://claude.com/product/claude-code) and [Cursor](https://www.cursor.com/) into LiveKit experts.
      
      - **[Python starter project](https://github.com/livekit-examples/agent-starter-python)**: Ready-to-go Python starter project. Clone a repo with all the code you need to get started.
      
      - **[Node.js starter project](https://github.com/livekit-examples/agent-starter-node)**: Ready-to-go Node.js starter project. Clone a repo with all the code you need to get started.
      
      ## Requirements
      
      The following sections describe the minimum requirements to get started with LiveKit Agents.
      
      **Python**:
      
      - LiveKit Agents requires Python >= 3.10.
      - This guide uses the [uv](https://docs.astral.sh/uv/getting-started/installation/) package manager.
      
      ---
      
      **Node.js**:
      
      - LiveKit Agents for Node.js requires Node.js >= 20.
      - This guide uses [pnpm](https://pnpm.io/installation) package manager and requires pnpm >= 10.15.0.
      
      ### LiveKit Cloud
      
      This guide assumes you have signed up for a free [LiveKit Cloud](https://cloud.livekit.io/) account. LiveKit Cloud includes agent deployment, model inference, and realtime media transport. Create a free project and use the API keys in the following steps to get started.
      
      While this guide assumes LiveKit Cloud, the instructions can be adapted for [self-hosting](https://docs.livekit.io/transport/self-hosting/local.md) the open source LiveKit server instead. For self-hosting in production, set up a [custom deployment](https://docs.livekit.io/deploy/custom/deployments.md) environment, and make the following changes: remove the [enhanced noise cancellation](https://docs.livekit.io/transport/media/noise-cancellation.md) plugin from the agent code, and use [plugins](https://docs.livekit.io/agents/models.md#plugins) for your own AI providers.
      
      ### LiveKit CLI
      
      Use the LiveKit CLI to manage LiveKit API keys and deploy your agent to LiveKit Cloud.
      
      1. Install the LiveKit CLI:
      
      **macOS**:
      
      Install the LiveKit CLI with [Homebrew](https://brew.sh/):
      
      ```text
      brew install livekit-cli
      
      ```
      
      ---
      
      **Linux**:
      
      ```text
      curl -sSL https://get.livekit.io/cli | bash
      
      ```
      
      > 💡 **Tip**
      > 
      > You can also download the latest precompiled binaries [here](https://github.com/livekit/livekit-cli/releases/latest).
      
      ---
      
      **Windows**:
      
      ```text
      winget install LiveKit.LiveKitCLI
      
      ```
      
      > 💡 **Tip**
      > 
      > You can also download the latest precompiled binaries [here](https://github.com/livekit/livekit-cli/releases/latest).
      
      ---
      
      **From Source**:
      
      This repo uses [Git LFS](https://git-lfs.github.com/) for embedded video resources. Please ensure git-lfs is installed on your machine before proceeding.
      
      ```text
      git clone github.com/livekit/livekit-cli
      make install
      
      ```
      2. Link your LiveKit Cloud project to the CLI:
      
      ```shell
      lk cloud auth
      
      ```
      
      This opens a browser window to authenticate and link your project to the CLI.
      
      ## Quickstart steps
      
      The following sections walk you through the steps to get your first agent running.
      
      ### Setup with CLI
      
      The simplest way to get your first agent running is with the LiveKit CLI.
      
      Make sure your project meets all [requirements](#requirements), then run:
      
      **Python**:
      
      ```shell
      lk agent init my-agent --template agent-starter-python
      
      ```
      
      ---
      
      **Node.js**:
      
      ```shell
      lk agent init my-agent --template agent-starter-node
      
      ```
      
      The CLI clones the template into the `my-agent` directory, creates an `.env.local` file with your LiveKit credentials, and prints the next steps to run your agent.
      
      > 💡 **Save the chat link**
      > 
      > Open the link provided by the CLI after the line `"To try your new agent in the web console, visit:"` to speak to your agent in the following step.
      
      Follow the instructions it prints, which guide you through the following steps:
      
      1. **Select a project to use** — If you don't have a default project set, the CLI prompts you to select a project to use.
      2. **Change into the project directory** — The project directory is named after your agent.
      
      ```shell
      cd my-agent
      
      ```
      3. **Install dependencies** — Install the agent's runtime and plugin dependencies if you did not electo have them automatically installed during template setup.
      
      **Python**:
      
      ```shell
      uv sync
      
      ```
      
      ---
      
      **Node.js**:
      
      ```shell
      pnpm install
      
      ```
      4. **Run your agent** — Run your agent in development mode.
      
      ```shell
      lk agent dev
      
      ```
      
      ### Speak to your agent
      
      If you opened the Console link provided by the CLI in the previous step, return to your browser and click **Start a session**. Otherwise, you can always find the Console on your project's [Agents dashboard](https://cloud.livekit.io/projects/p_/agents). Use the microphone button to speak to your agent and see its responses in real time, and explore the tool panes to measure your agent's behavior and performance in detail.
      
      ## Other options
      
      You can customize your agent by choosing different AI models and by exploring testing and deployment options.
      
      ### AI models
      
      Voice agents require one or more [AI models](https://docs.livekit.io/agents/models.md) to provide understanding, intelligence, and speech. LiveKit Agents supports both high-performance STT-LLM-TTS voice pipelines constructed from multiple specialized models, as well as realtime models with direct speech-to-speech capabilities. For help deciding which pipeline fits your use case, see [Pipeline types](https://docs.livekit.io/agents/models/pipelines.md).
      
      **STT-LLM-TTS pipeline**:
      
      Your agent strings together three specialized providers into a high-performance voice pipeline powered by LiveKit Inference. No additional setup is required.
      
      ![Diagram showing STT-LLM-TTS pipeline.](/images/agents/stt-llm-tts-pipeline.svg)
      
      | Component | Model | Alternatives |
      | STT | Deepgram Nova-3 | [STT models](https://docs.livekit.io/agents/models/stt.md) |
      | LLM | Gemma 4 31B | [LLM models](https://docs.livekit.io/agents/models/llm.md) |
      | TTS | Inworld TTS-2 | [TTS models](https://docs.livekit.io/agents/models/tts.md) |
      
      ---
      
      **Realtime model**:
      
      Your agent uses a single realtime model to provide an expressive and lifelike voice experience.
      
      ![Diagram showing realtime model.](/images/agents/realtime-model.svg)
      
      | Model | Required Key | Alternatives |
      | [OpenAI Realtime API](https://developers.openai.com/docs/guides/realtime) | `OPENAI_API_KEY` | [Realtime models](https://docs.livekit.io/agents/models/realtime.md) |
      
      You can change the AI models used by editing your agent file. Full agent files for STT-LLM-TTS and Realtime models can be found in the [Agent code](#agent-code) section.
      
      ### Test and deploy
      
      Use different modes and deployment options to test and deploy your agent.
      
      #### Server startup modes
      
      Start your agent server in development or production modes.
      
      - `console` mode: Run your agent locally in your terminal.
      - `dev` mode: Run your agent in development mode for testing and debugging.
      - `start` mode: Run your agent in production mode.
      
      To learn more about these modes, see the [Server startup modes](https://docs.livekit.io/agents/server/startup-modes/) reference.
      
      To run your agent in production mode:
      
      ```shell
      lk agent start
      
      ```
      
      #### Connect to Agent Console
      
      Start your agent in `dev` mode to connect it to LiveKit and make it available from anywhere on the internet:
      
      ```shell
      lk agent dev
      
      ```
      
      Use the [Agent Console](https://docs.livekit.io/agents/start/console.md) to interact with and debug your agent in realtime. Note that you'll need to set the **Agent name**, which should be `my-agent` for this quickstart.
      
      #### Deploy to LiveKit Cloud
      
      Run `lk agent create` from the project directory to register and deploy.
      
      After the deployment completes, you can access your agent in [Agent Console](https://docs.livekit.io/agents/start/console.md), or continue to use the `console` mode as you build and test your agent locally.
      
      ## Agent code
      
      Once you have the quickstart running, you can dig into the agent code. For the difference between realtime and chained (STT-LLM-TTS) pipelines, see [AI models](#ai-models). The tabs below show the full files for each pipeline type so you can swap, copy, or adapt them.
      
      **STT-LLM-TTS pipeline**:
      
      ** Filename: `agent.py`**
      
      ```python
      from dotenv import load_dotenv
      
      from livekit import agents
      from livekit.agents import AgentServer, AgentSession, Agent, inference, room_io, TurnHandlingOptions
      from livekit.plugins import ai_coustics
      
      load_dotenv(".env.local")
      
      
      class Assistant(Agent):
          def __init__(self) -> None:
              super().__init__(
                  instructions="""You are a helpful voice AI assistant.
                  You eagerly assist users with their questions by providing information from your extensive knowledge.
                  Your responses are concise, to the point, and without any complex formatting or punctuation including emojis, asterisks, or other symbols.
                  You are curious, friendly, and have a sense of humor.""",
              )
      
      server = AgentServer()
      
      @server.rtc_session(agent_name="my-agent")
      async def my_agent(ctx: agents.JobContext):
          session = AgentSession(
              stt=inference.STT(model="deepgram/nova-3", language="multi"),
              llm=inference.LLM(model="google/gemma-4-31b-it"),
              tts=inference.TTS(
                  model="inworld/inworld-tts-2",
                  voice="Ashley",
              ),
              turn_handling=TurnHandlingOptions(
                  turn_detection=inference.TurnDetector(),
              ),
          )
      
          await session.start(
              room=ctx.room,
              agent=Assistant(),
              room_options=room_io.RoomOptions(
                  audio_input=room_io.AudioInputOptions(
                      noise_cancellation=ai_coustics.audio_enhancement(model=ai_coustics.EnhancerModel.QUAIL_VF_S),
                  ),
              ),
          )
      
          await session.generate_reply(
              instructions="Greet the user and offer your assistance."
          )
      
      
      if __name__ == "__main__":
          agents.cli.run_app(server)
      
      
      ```
      
      ** Filename: `main.ts`**
      
      ```typescript
      import {
        type JobContext,
        ServerOptions,
        cli,
        defineAgent,
        inference,
        voice,
      } from '@livekit/agents';
      import * as aiCoustics from '@livekit/plugins-ai-coustics';
      import { fileURLToPath } from 'node:url';
      import dotenv from 'dotenv';
      import { createAgent } from './agent';
      
      dotenv.config({ path: '.env.local' });
      
      export default defineAgent({
        entry: async (ctx: JobContext) => {
          const session = new voice.AgentSession({
            stt: new inference.STT({ model: 'deepgram/nova-3', language: 'multi' }),
            llm: new inference.LLM({ model: 'google/gemma-4-31b-it' }),
            tts: new inference.TTS({
              model: 'inworld/inworld-tts-2',
              voice: 'Ashley',
            }),
            turnHandling: {
              turnDetection: new inference.TurnDetector(),
            },
          });
      
          await session.start({
            agent: createAgent(),
            room: ctx.room,
            inputOptions: {
              noiseCancellation: aiCoustics.audioEnhancement({ model: 'quailVfS' }),
            },
          });
      
          await ctx.connect();
      
          const handle = session.generateReply({
            instructions: 'Greet the user and offer your assistance.',
          });
        },
      });
      
      cli.runApp(new ServerOptions({ agent: fileURLToPath(import.meta.url), agentName: 'my-agent' }));
      
      ```
      
      ** Filename: `agent.ts`**
      
      ```typescript
      import { voice } from '@livekit/agents';
      
      export function createAgent() {
        return voice.Agent.create({
          instructions: `You are a helpful voice AI assistant.
            You eagerly assist users with their questions by providing information from your extensive knowledge.
            Your responses are concise, to the point, and without any complex formatting or punctuation including emojis, asterisks, or other symbols.
            You are curious, friendly, and have a sense of humor.`,
        });
      }
      
      ```
      
      ---
      
      **Realtime model**:
      
      ** Filename: `agent.py`**
      
      ```python
      from dotenv import load_dotenv
      
      from livekit import agents
      from livekit.agents import AgentServer, AgentSession, Agent, room_io
      from livekit.plugins import (
          openai,
          ai_coustics,
      )
      
      load_dotenv(".env.local")
      
      class Assistant(Agent):
          def __init__(self) -> None:
              super().__init__(instructions="You are a helpful voice AI assistant.")
      
      server = AgentServer()
      
      @server.rtc_session(agent_name="my-agent")
      async def my_agent(ctx: agents.JobContext):
          session = AgentSession(
              llm=openai.realtime.RealtimeModel(
                  voice="coral"
              )
          )
      
          await session.start(
              room=ctx.room,
              agent=Assistant(),
              room_options=room_io.RoomOptions(
                  audio_input=room_io.AudioInputOptions(
                      noise_cancellation=ai_coustics.audio_enhancement(model=ai_coustics.EnhancerModel.QUAIL_VF_S),
                  ),
              ),
          )
      
          await session.generate_reply(
              instructions="Greet the user and offer your assistance. You should start by speaking in English."
          )
      
      
      if __name__ == "__main__":
          agents.cli.run_app(server)
      
      
      ```
      
      ** Filename: `main.ts`**
      
      ```typescript
      import {
        type JobContext,
        ServerOptions,
        cli,
        defineAgent,
        voice,
      } from '@livekit/agents';
      import * as openai from '@livekit/agents-plugin-openai';
      import * as aiCoustics from '@livekit/plugins-ai-coustics';
      import { fileURLToPath } from 'node:url';
      import dotenv from 'dotenv';
      import { createAgent } from './agent';
      
      dotenv.config({ path: '.env.local' });
      
      export default defineAgent({
        entry: async (ctx: JobContext) => {
          const session = new voice.AgentSession({
            llm: new openai.realtime.RealtimeModel({
              voice: 'coral',
            }),
          });
      
          await session.start({
            agent: createAgent(),
            room: ctx.room,
            inputOptions: {
              noiseCancellation: aiCoustics.audioEnhancement({ model: 'quailVfS' }),
            },
          });
      
          await ctx.connect();
      
          await session.generateReply({
            instructions: 'Greet the user and offer your assistance. You should start by speaking in English.',
          });
        },
      });
      
      cli.runApp(new ServerOptions({ agent: fileURLToPath(import.meta.url), agentName: 'my-agent' }));
      
      ```
      
      ** Filename: `agent.ts`**
      
      ```typescript
      import { voice } from '@livekit/agents';
      
      export function createAgent() {
        return voice.Agent.create({
          instructions: 'You are a helpful voice AI assistant.',
        });
      }
      
      ```
      
      ## Next steps
      
      Follow these guides to bring your voice AI app to life in the real world.
      
      - **[Web and mobile frontends](https://docs.livekit.io/agents/start/frontend.md)**: Put your agent in your pocket with a custom web or mobile app.
      
      - **[Telephony integration](https://docs.livekit.io/agents/start/telephony.md)**: Your agent can place and receive calls with LiveKit's SIP integration.
      
      - **[Testing your agent](https://docs.livekit.io/agents/start/testing.md)**: Add behavioral tests to fine-tune your agent's behavior.
      
      - **[Building voice agents](https://docs.livekit.io/agents/build.md)**: Comprehensive documentation to build advanced voice AI apps with LiveKit.
      
      - **[Agent server](https://docs.livekit.io/agents/server.md)**: Learn how to manage your agents with agent servers and jobs.
      
      - **[Deploying to LiveKit Cloud](https://docs.livekit.io/agents/ops/deployment.md)**: Learn more about deploying and scaling your agent in production.
      
      - **[AI Models](https://docs.livekit.io/agents/models.md)**: Explore the full list of AI models available with LiveKit Agents.
      
      - **[Recipes](https://docs.livekit.io/reference/recipes.md)**: A comprehensive collection of examples, guides, and recipes for LiveKit Agents.
      
      ---
      
      For the latest version of this document, see [https://docs.livekit.io/agents/start/voice-ai.md](https://docs.livekit.io/agents/start/voice-ai.md).
      
      To explore all LiveKit documentation, see [llms.txt](https://docs.livekit.io/llms.txt).
      
    • self-hosting.md 1.3 KB
      ## /home/self-hosting
      
      LiveKit docs › WebRTC Transport › Self-hosting › Running locally
      
      ---
      
      # Running LiveKit locally
      
      > This will get a LiveKit instance up and running, ready to receive audio and video streams from participants.
      
      ### Install LiveKit Server
      
      **macOS**:
      
      ```text
      brew update && brew install livekit
      
      ```
      
      ---
      
      **Linux**:
      
      ```text
      curl -sSL https://get.livekit.io | bash
      
      ```
      
      ---
      
      **Windows**:
      
      Download the latest release [here](https://github.com/livekit/livekit/releases/latest).
      
      ### Start the server in dev mode
      
      You can start LiveKit in development mode by running:
      
      ```text
      livekit-server --dev
      
      ```
      
      This will start an instance using the following API key/secret pair:
      
      ```text
      API key: devkey
      API secret: secret
      
      ```
      
      To customize your setup for production, refer to our [deployment guides](https://docs.livekit.io/transport/self-hosting/deployment.md).
      
      > 💡 **Tip**
      > 
      > By default LiveKit's signal server binds to `127.0.0.1:7880`. If you'd like to access it from other devices on your network, pass in `--bind 0.0.0.0`
      
      ---
      
      For the latest version of this document, see [https://docs.livekit.io/transport/self-hosting/local.md](https://docs.livekit.io/transport/self-hosting/local.md).
      
      To explore all LiveKit documentation, see [llms.txt](https://docs.livekit.io/llms.txt).
      
  • SKILL.md 14.2 KB
    ---
    name: livekit-skills
    description: 'Build voice AI agents with LiveKit Agents SDK. Use when the user asks to "build a voice agent", "create a LiveKit agent", "add voice AI", "implement handoffs", "structure agent workflows", or is working with LiveKit Agents SDK. Covers both LiveKit Cloud and self-hosted deployments using lk CLI.'
    license: MIT
    metadata:
      author: livekit
      version: "0.3.1"
    ---
    
    # LiveKit Voice Agent Development
    
    This skill provides guidance for building voice AI agents with the LiveKit Agents SDK. It covers both LiveKit Cloud and self-hosted deployments, using the `lk` CLI for documentation access and project management. All factual information about APIs, methods, and configurations must come from live documentation.
    
    
    ## MANDATORY: Read This Checklist Before Starting
    
    Before writing ANY code, complete this checklist:
    
    1. **Read this entire skill document** - Do not skip sections
    2. **Set up LiveKit credentials** (Cloud project or self-hosted server) - You need `LIVEKIT_URL`, `LIVEKIT_API_KEY`, and `LIVEKIT_API_SECRET`
    3. **Set up documentation access** - Install `lk` CLI for `lk docs` commands
    4. **Plan to write tests** - Every agent implementation MUST include tests (see testing section below)
    5. **Verify all APIs against live docs** - Never rely on model memory for LiveKit APIs
    
    
    ## Setup
    
    ### LiveKit Cloud
    
    LiveKit Cloud is the fastest way to get a voice agent running. It provides:
    - Managed infrastructure (no servers to deploy)
    - **LiveKit Inference** for AI models (no separate API keys needed)
    - Built-in noise cancellation, turn detection, and other voice features
    - Simple credential management
    
    ### Connect to Your Cloud Project
    
    1. Sign up at [cloud.livekit.io](https://cloud.livekit.io) if you haven't already
    2. Create a project (or use an existing one)
    3. Get your credentials from the project settings:
       - `LIVEKIT_URL` - Your project's WebSocket URL (e.g., `wss://your-project.livekit.cloud`)
       - `LIVEKIT_API_KEY` - API key for authentication
       - `LIVEKIT_API_SECRET` - API secret for authentication
    
    4. Set these as environment variables (typically in `.env.local`):
    ```bash
    LIVEKIT_URL=wss://your-project.livekit.cloud
    LIVEKIT_API_KEY=your-api-key
    LIVEKIT_API_SECRET=your-api-secret
    ```
    
    The LiveKit CLI can automate credential setup. Consult the CLI documentation for current commands.
    
    ### Use LiveKit Inference for AI Models
    
    LiveKit Inference is one option for AI model access when using LiveKit Cloud. It provides access to leading AI model providers—all through your LiveKit credentials with no separate API keys needed.
    
    Benefits of LiveKit Inference:
    - No separate API keys to manage for each AI provider
    - Billing consolidated through your LiveKit Cloud account
    - Optimized for voice AI workloads
    
    Consult the documentation for available models, supported providers, and current usage patterns. The documentation always has the most up-to-date information.
    
    ### Self-Hosted Setup
    
    Self-hosting removes Cloud tier limits on deployments and concurrency. You control scaling directly.
    
    #### Local development
    Install and run the LiveKit server:
    - macOS: `brew install livekit`
    - Linux: `curl -sSL https://get.livekit.io | bash`
    
    Start in dev mode:
    ```bash
    livekit-server --dev
    ```
    Default credentials: API key `devkey`, API secret `secret`.
    
    Set environment variables:
    ```bash
    LIVEKIT_URL=ws://localhost:7880
    LIVEKIT_API_KEY=devkey
    LIVEKIT_API_SECRET=secret
    ```
    
    #### Production deployment
    Deploy `livekit-server` via Docker, Kubernetes, or VMs on any provider (Hetzner, AWS, GCP, etc.). Consult `lk docs get-page /home/self-hosting` or see `references/self-hosting.md` for details. Agent servers run as regular processes managed by your infra tooling.
    
    ### Using Your Own Model Providers
    
    When self-hosting or when you prefer your own API keys over LiveKit Inference, configure model providers directly via environment variables:
    
    ```bash
    # STT (Speech-to-Text)
    DEEPGRAM_API_KEY=your-key
    
    # LLM
    OPENAI_API_KEY=your-key
    
    # TTS (Text-to-Speech)
    ELEVEN_API_KEY=your-key
    # or
    CARTESIA_API_KEY=your-key
    ```
    
    The Agents SDK has plugins for all major providers. Pass model identifiers directly:
    
    **Node.js / TypeScript:**
    ```typescript
    import { voice } from "@livekit/agents";
    
    const session = new voice.AgentSession({
      stt: "deepgram/nova-3:multi",
      llm: "openai/gpt-4.1-mini",
      tts: "cartesia/sonic-3:voice-id",  // or "elevenlabs/..."
    });
    ```
    
    **Python:**
    ```python
    session = AgentSession(
        stt="deepgram/nova-3",
        llm="openai/gpt-4.1-mini",
        tts="elevenlabs/...",  # or "cartesia/sonic-3:voice-id"
    )
    ```
    
    Consult `lk docs search "plugins"` for the full list of supported providers.
    
    ### Project Templates
    
    Initialize a new agent project with the CLI:
    
    **Backend agents:**
    ```bash
    lk agent init my-agent --template agent-starter-python
    lk agent init my-agent --template agent-starter-node
    ```
    
    **Frontend apps (React/Next.js, React Native, Swift, Flutter, Android):**
    ```bash
    lk agent init my-frontend --template agent-starter-react
    lk agent init my-frontend --template agent-starter-react-native
    ```
    
    Omit `--template` to see all available templates interactively.
    
    ## Critical Rule: Never Trust Model Memory for LiveKit APIs
    
    LiveKit Agents is a fast-evolving SDK. Model training data is outdated the moment it's created. When working with LiveKit:
    
    - **Never assume** API signatures, method names, or configuration options from memory
    - **Never guess** SDK behavior or default values
    - **Always verify** against live documentation before writing code
    - **Always cite** the documentation source when implementing features
    
    This rule applies even when confident about an API. Verify anyway.
    
    ## Use LiveKit CLI for Documentation
    
    Before writing any LiveKit code, use the `lk docs` CLI commands for current, verified API information. This prevents reliance on stale model knowledge.
    
    ### Search documentation
    ```bash
    lk docs search "voice agent quickstart"
    lk docs search "handoffs and tasks"
    ```
    
    ### Fetch specific pages
    ```bash
    lk docs get-page /agents/start/voice-ai-quickstart
    lk docs get-page /agents/build/tools /agents/build/vision
    ```
    
    ### Search SDK source code
    ```bash
    lk docs code-search "class AgentSession" --repo livekit/agents
    lk docs code-search "@function_tool" --language Python --full-file
    ```
    
    ### Check changelogs
    ```bash
    lk docs changelog livekit/agents
    lk docs changelog pypi:livekit-agents --releases 5
    lk docs changelog npm:livekit-agents --releases 5
    ```
    
    ### If CLI is not installed
    Install the LiveKit CLI first:
    - macOS: `brew install livekit-cli`
    - Linux: `curl -sSL https://get.livekit.io/cli | bash`
    - Windows: `winget install LiveKit.LiveKitCLI`
    
    As a fallback, reference pages are available in the `references/` directory alongside this skill.
    
    ## Voice Agent Architecture Principles
    
    Voice AI agents have fundamentally different requirements than text-based agents or traditional software. Internalize these principles:
    
    ### Latency Is Critical
    
    Voice conversations are real-time. Users expect responses within hundreds of milliseconds, not seconds. Every architectural decision should consider latency impact:
    
    - Minimize LLM context size to reduce inference time
    - Avoid unnecessary tool calls during active conversation
    - Prefer streaming responses over batch responses
    - Design for the unhappy path (network delays, API timeouts)
    
    ### Context Bloat Kills Performance
    
    Large system prompts and extensive tool lists directly increase latency. A voice agent with 50 tools and a 10,000-token system prompt will feel sluggish regardless of model speed.
    
    Design agents with minimal viable context:
    - Include only tools relevant to the current conversation phase
    - Keep system prompts focused and concise
    - Remove tools and context that aren't actively needed
    
    ### Users Don't Read, They Listen
    
    Voice interface constraints differ from text:
    - Long responses frustrate users—keep outputs concise
    - Users cannot scroll back—ensure clarity on first delivery
    - Interruptions are normal—design for graceful handling
    - Silence feels broken—acknowledge processing when needed
    
    ## Workflow Architecture: Handoffs and Tasks
    
    Complex voice agents should not be monolithic. LiveKit Agents supports structured workflows that maintain low latency while handling sophisticated use cases.
    
    ### The Problem with Monolithic Agents
    
    A single agent handling an entire conversation flow accumulates:
    - Tools for every possible action (bloated tool list)
    - Instructions for every conversation phase (bloated context)
    - State management for all scenarios (complexity)
    
    This creates latency and reduces reliability.
    
    ### Handoffs: Agent-to-Agent Transitions
    
    Handoffs allow one agent to transfer control to another. Use handoffs to:
    - Separate distinct conversation phases (greeting → intake → resolution)
    - Isolate specialized capabilities (general support → billing specialist)
    - Manage context boundaries (each agent has only what it needs)
    
    Design handoffs around natural conversation boundaries where context can be summarized rather than transferred wholesale.
    
    ### Tasks: Scoped Operations
    
    Tasks are tightly-scoped prompts designed to achieve a specific outcome. Use tasks for:
    - Discrete operations that don't require full agent capabilities
    - Situations where a focused prompt outperforms a general-purpose agent
    - Reducing context when only a specific capability is needed
    
    Consult the documentation for implementation details on handoffs and tasks.
    
    ## REQUIRED: Write Tests for Agent Behavior
    
    Voice agent behavior is code. Every agent implementation MUST include tests. Shipping an agent without tests is shipping untested code.
    
    ### Mandatory Testing Workflow
    
    When building or modifying a LiveKit agent:
    
    1. **Create a `tests/` directory** if one doesn't exist
    2. **Write at least one test** before considering the implementation complete
    3. **Test the core behavior** the user requested
    4. **Run the tests** to verify they pass
    
    ### Test-Driven Development Process
    
    When modifying agent behavior—instructions, tool descriptions, workflows—begin by writing tests for the desired behavior:
    
    1. Define what the agent should do in specific scenarios
    2. Write test cases that verify this behavior
    3. Implement the feature
    4. Iterate until tests pass
    
    This approach prevents shipping agents that "seem to work" but fail in production.
    
    ### What Every Agent Test Should Cover
    
    At minimum, write tests for:
    - **Basic conversation flow**: Agent responds appropriately to a greeting
    - **Tool invocation** (if tools exist): Tools are called with correct parameters
    - **Error handling**: Agent handles unexpected input gracefully
    
    Focus tests on:
    - **Tool invocation**: Does the agent call the right tools with correct parameters?
    - **Response quality**: Does the agent produce appropriate responses for given inputs?
    - **Workflow transitions**: Do handoffs and tasks trigger correctly?
    - **Edge cases**: How does the agent handle unexpected input, interruptions, silence?
    
    ### Test Implementation Pattern
    
    Use LiveKit's testing framework. Consult the testing documentation via `lk docs` for current patterns:
    ```
    search: "livekit agents testing"
    ```
    
    The framework supports:
    - Simulated user input
    - Verification of agent responses
    - Tool call assertions
    - Workflow transition testing
    
    ### Why This Is Non-Negotiable
    
    Agents that "seem to work" in manual testing frequently fail in production:
    - Prompt changes silently break behavior
    - Tool descriptions affect when tools are called
    - Model updates change response patterns
    
    Tests catch these issues before users do.
    
    ### Skipping Tests
    
    If a user explicitly requests no tests, proceed without them but inform them:
    > "I've built the agent without tests as requested. I strongly recommend adding tests before deploying to production. Voice agents are difficult to verify manually and tests prevent silent regressions."
    
    ## Common Mistakes to Avoid
    
    ### Overloading the Initial Agent
    
    Starting with one agent that "does everything" and adding tools/instructions over time. Instead, design workflow structure upfront, even if initial implementation is simple.
    
    ### Ignoring Latency Until It's a Problem
    
    Latency issues compound. An agent that feels "a bit slow" in development becomes unusable in production with real network conditions. Measure and optimize latency continuously.
    
    ### Copying Examples Without Understanding
    
    Examples in documentation demonstrate specific patterns. Copying code without understanding its purpose leads to bloated, poorly-structured agents. Understand what each component does before including it.
    
    ### Skipping Tests Because "It's Just Prompts"
    
    Agent behavior is code. Prompt changes affect behavior as much as code changes. Test agent behavior with the same rigor as traditional software. **Never deliver an agent implementation without at least one test file.**
    
    ### Assuming Model Knowledge Is Current
    
    Reiterating the critical rule: never trust model memory for LiveKit APIs. The SDK evolves faster than model training cycles. Verify everything.
    
    ## When to Consult Documentation
    
    **Always consult documentation for:**
    - API method signatures and parameters
    - Configuration options and their valid values
    - SDK version-specific features or changes
    - Deployment and infrastructure setup
    - Model provider integration details
    - CLI commands and flags
    
    **This skill provides guidance on:**
    - Architectural approach and design principles
    - Workflow structure decisions
    - Testing strategy
    - Common pitfalls to avoid
    
    The distinction matters: this skill tells you *how to think* about building voice agents. The documentation tells you *how to implement* specific features.
    
    ## Feedback Loop
    
    When using LiveKit documentation via `lk docs`, note any gaps, outdated information, or confusing content. Reporting documentation issues helps improve the ecosystem for all developers.
    
    ## Summary
    
    Building effective voice agents with LiveKit Cloud requires:
    
    1. **Use LiveKit Cloud + LiveKit Inference** as the foundation—it's the fastest path to production
    2. **Verify everything** against live documentation—never trust model memory
    3. **Minimize latency** at every architectural decision point
    4. **Structure workflows** using handoffs and tasks to manage complexity
    5. **Test behavior** before and after changes—never ship without tests
    6. **Keep context minimal**—only include what's needed for the current phase
    
    These principles remain valid regardless of SDK version or API changes. For all implementation specifics, consult the LiveKit documentation via `lk docs`.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related