Skip to main content

Bridge external AI agent frameworks (LangChain, LangGraph, Strands, ADK, custom) to the LiveKit Agent runtime.

Project description

LiveKit Agents Adapter

Bridge any external AI agent framework to the LiveKit Agent runtime.

Overview

This package provides AgentAdapter, a livekit.agents.voice.Agent subclass that delegates LLM inference to an external framework (LangChain, LangGraph, Strands, ADK, custom code, etc.) via a pluggable Translator interface.

The adapter is a pure pass-through:

  1. Converts LiveKit's ChatContext to the external framework's native format
  2. Forwards text and tool calls streamed from the external framework into LiveKit's llm_node
  3. Syncs conversation history back to the LiveKit ChatContext after each turn

Tool calls are handled entirely within the external framework. The adapter does not execute tools. When the external framework streams a ToolCall, it is forwarded to LiveKit's ChatContext for transcript/logging purposes only. The external framework decides when and how to stream its final text response.

Quick Start

from livekit_agents_adapter import AgentAdapter, AgentAdapterConfig, Translator, TextChunk, Done


class MyTranslator(Translator):
    async def invoke(self, chat_ctx, tools):
        yield TextChunk(content="Hello!", is_final=True)
        yield Done(metadata={})

    # ... implement to_external_chat_ctx, to_external_tools, sync_back_messages


agent = AgentAdapter(
    config=AgentAdapterConfig(translator=MyTranslator(my_agent)),
    instructions="You are a helpful voice assistant.",
)

# Use like any LiveKit Agent in AgentSession...
await session.start(agent=agent, room=room)

Writing a Translator

Subclass Translator (an abc.ABC) and implement four required methods:

from livekit_agents_adapter import Translator, TextChunk, ToolCall, Done


class MyTranslator(Translator):
    async def to_external_chat_ctx(self, chat_ctx):
        # Convert LiveKit ChatContext → your framework's format
        return my_framework_messages

    async def to_external_tools(self, tools):
        # Convert LiveKit llm.Tool → your framework's tool format
        return my_framework_tools

    async def invoke(self, chat_ctx, tools):
        # Stream responses from your framework.
        # The adapter forwards TextChunk to TTS, ToolCall to ChatContext.
        # Yield Done to signal end of turn.
        async for chunk in my_framework_stream(chat_ctx, tools):
            yield TextChunk(content=chunk)  # or ToolCall(...)

        yield Done(metadata={})

    async def sync_back_messages(self, chat_ctx):
        # Return new ChatItems for the adapter to insert into ChatContext.
        from livekit_agents_adapter.translators.chat_context import sync_from_list_to_items

        return sync_from_list_to_items(self._messages[self._last_synced_count :])

Installation

# Core package
pip install livekit-agents-adapter

# With LangChain support
pip install livekit-agents-adapter-langchain

More

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

livekit_agents_adapter-0.1.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

livekit_agents_adapter-0.1.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file livekit_agents_adapter-0.1.1.tar.gz.

File metadata

File hashes

Hashes for livekit_agents_adapter-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0801528b22bc4ce113a59d82f9b9065d6a8b37a2601ee71c715a1eaeefc508ca
MD5 8db28e3c4fcc4490bfa967f0f374a069
BLAKE2b-256 226d4683882051561b07881825e4e8df7a68d636aa4cfcf8a02fa350e5b0137d

See more details on using hashes here.

File details

Details for the file livekit_agents_adapter-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for livekit_agents_adapter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa535276c0588d9be47860205efeb675835eecc7268a54d8a7539d89666a5ec3
MD5 2c73c3bbb0ba11b674293a13172ee0f1
BLAKE2b-256 db0c7a5765c0dfdb171625c1f0e1148aa35796c4bc4919e62e363e8e969d4c2e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page