LiveKit Agents 2.0
An Agent defines behavior. TextSession coordinates a conversation across
requests; VoiceSession runs an active voice conversation. Application context
carries data and services, with explicit persistence for selected fields.
These documents define the intended API and behavior.
Start here
- Agents: define behavior, register a tool, run an invocation, and read its result.
- Tools: tool execution, human input, approvals, and agents as tools.
- Context: declare application data and construct runtime dependencies.
- Persistence: load/save fields, bind session state, and choose transaction boundaries.
- Conversation state and delegation: inspect local and remote work and keep the frontend responsive.
- Choose TextSession for request-scoped text conversations or VoiceSession for a live call.
For the proposed replacement of AsyncToolset with @task, read
tasks and conversational A2A. This is a docs-only design awaiting
approval before implementation. Task-related changes linked from the guides are target
behavior; current runtime differences are identified explicitly.
For bounded voice interactions, continue with VoiceTask. To expose and call your application, read server entrypoints and clients.
Public API
| Document | Owns |
|---|---|
| agents.md | Agent configuration, RunContext, execution, output contracts, history, lifecycle hooks, and streaming |
| tools.md | Tool declaration, toolsets/MCP, approvals, human input, errors and local/remote tool configuration |
| models.md | Model strings and the inference catalog, realtime options, connection options and pools, the HTTP/WebSocket client, timeouts, errors, retries, provider streams, and the plugin-author contract |
| telemetry.md | Exporting to your backend, application spans, distributed traces, content and PII, LiveKit Cloud recording, and Prometheus |
| usage.md | Usage snapshots, token and billing units, accounting scope, measurement availability, and performance metrics |
| context.md | Runtime dependencies, persisted field declarations, context scopes, and schema evolution |
| persistence.md | Explicit load/save, session binding and snapshots, durability, transactions, and concurrent updates |
| session-state.md | Shared conversation state, local agent/call views, perceived and private histories, remote observation views and input lifecycles |
| delegation.md | Responsive frontend behavior, response recognition, remote task selection, progress/exact delivery and remote work recovery |
| text-session.md | Text execution, local agents as tools, approval and continuation across requests |
| voice-session.md | Audio and turn configuration, agent replacement, frontend expert events, and reply routing |
| lexer.md | A model reply's text on its way to the voice, the transcript and the history: hidden reasoning and template leaks, expressive markup, markdown and emoji, transcript sync, and how long text is held |
| voice-tasks.md | Constructing and running bounded voice interactions, typed completion, suspension, and cleanup |
| threads.md | Conversation identity, lifecycle, public history/task access, and the relationship between partitions and local agent state |
| server.md | AgentServer/AgentHandler, text and voice entrypoints, handler outcomes, and request policies |
| clients.md | Thread service and handles, endpoint clients, grants, browser access, and call dispatch |
| auth.md | Principals, grants, how a thread id travels with its token, agent-db access, and endpoint verification |
| channels.md | Platform ingress/egress, SMS/WhatsApp/email, attachments, and cross-channel continuation |
| testing.md | Run event assertions, conversation judges, simulations, and SimulationContext verdicts and callbacks |
Each contract has one owning page. Other pages show how to use it and link to
its definition. Keep shared rules, defaults, exhaustive option tables and failure
semantics in that owner; examples elsewhere should explain only their specific
use. Public behavior and implementation mechanics have separate owners. Run
results and streaming live in agents.md; wire encoding and storage mechanics
have separate references below.
Protocol
| Document | Contract |
|---|---|
| A2A | Agent cards, wire tasks, metadata, tokens, errors, and third-party interoperability |
Internals
The contributor index organizes the implementation guides by topic. Start with the execution paths to follow an execution path, or development to build and check the framework.
Principles
Typed end to end, in Python and in Node.
- No
Anyin the public API: every function, class and callback is fully typed, user code passes mypy strict and pyright, and the Node package ships.d.tsfiles with noany. - Generics carry the types:
Agent[Context, Output], inferred fromcontext_type=andoutput_type=,RunContext[Context]and typed run results. A typo inctx.context.xis a type error. - Data at every boundary is a validated type: persisted application data, output and tool arguments are validated schemas in Python and typed in Node. Local context can be an arbitrary Python object and is not automatically serialized.
- The wire is typed: A2A frames, grants, threads service calls and LiveKit metadata are records generated from one declaration and shared by Python and Node.
- CI enforces it: the examples type-check (mypy strict,
tsc), type tests pin the generics, and generated stubs must match their Rust declarations.
Running the examples
examples/: three fast brain and slow brain pairs, each one worker: a dental practice's front desk, a hotel receptionist, an airline's customer care, with simulation scenarios.tests/e2e/contains pytest journeys selected withuv run pytest tests/e2e --e2e: a thread across two workers, interrupt, an inbox burst, a worker killed mid-turn, input-required and approvals answered on the other worker, a stateless agent serving two threads, and the threads service's create and delete.
Vocabulary
| Term | Meaning |
|---|---|
| Agent | Shared behavior configuration; not a conversation or mutable application state |
| Task (proposed) | Tracked work declared with @task, exposed with .as_tool() or started explicitly; independent of a message, run or transport |
| Run | One input to a completed result or input-required outcome, including model/tool execution |
| Text session | Request-scoped conversation execution continued through a context store binding |
| Voice session | A running frontend conversation with audio resources, turn handling, and in-process interaction state |
| Voice task | A temporary voice interaction that returns a typed result and restores its caller |
| Thread | A durable conversation identity (AT_...), also used as A2A contextId |
| Partition | History, routing, inbox and write ownership selected by a partition_key within a thread |
| Agent state | One local agent context in SessionState, with private history and an originating parent call when it is a child |